<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-comment">{-
(c) The University of Glasgow 2006
(c) The GRASP/AQUA Project, Glasgow University, 1992-1998

-}</span><span>
</span><span id="line-6"></span><span>
</span><span id="line-7"></span><span class="hs-pragma">{-# LANGUAGE TypeFamilies #-}</span><span>
</span><span id="line-8"></span><span>
</span><span id="line-9"></span><span class="hs-comment">-- | Error-checking and other utilities for @deriving@ clauses or declarations.</span><span>
</span><span id="line-10"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">GHC.Tc.Deriv.Utils</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-11"></span><span>        </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivM"><span class="hs-identifier">DerivM</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivEnv"><span class="hs-identifier">DerivEnv</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-12"></span><span>        </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpec"><span class="hs-identifier">DerivSpec</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#pprDerivSpec"><span class="hs-identifier">pprDerivSpec</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivInstTys"><span class="hs-identifier">DerivInstTys</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-13"></span><span>        </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpecMechanism"><span class="hs-identifier">DerivSpecMechanism</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#derivSpecMechanismToStrategy"><span class="hs-identifier">derivSpecMechanismToStrategy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#isDerivSpecStock"><span class="hs-identifier">isDerivSpecStock</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-14"></span><span>        </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#isDerivSpecNewtype"><span class="hs-identifier">isDerivSpecNewtype</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#isDerivSpecAnyClass"><span class="hs-identifier">isDerivSpecAnyClass</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#isDerivSpecVia"><span class="hs-identifier">isDerivSpecVia</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-15"></span><span>        </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivContext"><span class="hs-identifier">DerivContext</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#OriginativeDerivStatus"><span class="hs-identifier">OriginativeDerivStatus</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-16"></span><span>        </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#isStandaloneDeriv"><span class="hs-identifier">isStandaloneDeriv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#isStandaloneWildcardDeriv"><span class="hs-identifier">isStandaloneWildcardDeriv</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#mkDerivOrigin"><span class="hs-identifier">mkDerivOrigin</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-17"></span><span>        </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#PredOrigin"><span class="hs-identifier">PredOrigin</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#ThetaOrigin"><span class="hs-identifier">ThetaOrigin</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#mkPredOrigin"><span class="hs-identifier">mkPredOrigin</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-18"></span><span>        </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#mkThetaOrigin"><span class="hs-identifier">mkThetaOrigin</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#mkThetaOriginFromPreds"><span class="hs-identifier">mkThetaOriginFromPreds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#substPredOrigin"><span class="hs-identifier">substPredOrigin</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-19"></span><span>        </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#checkOriginativeSideConditions"><span class="hs-identifier">checkOriginativeSideConditions</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#hasStockDeriving"><span class="hs-identifier">hasStockDeriving</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-20"></span><span>        </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#canDeriveAnyClass"><span class="hs-identifier">canDeriveAnyClass</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-21"></span><span>        </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#std_class_via_coercible"><span class="hs-identifier">std_class_via_coercible</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#non_coercible_class"><span class="hs-identifier">non_coercible_class</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-22"></span><span>        </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#newDerivClsInst"><span class="hs-identifier">newDerivClsInst</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#extendLocalInstEnv"><span class="hs-identifier">extendLocalInstEnv</span></a></span><span>
</span><span id="line-23"></span><span>    </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-24"></span><span>
</span><span id="line-25"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Prelude.html"><span class="hs-identifier">GHC.Prelude</span></a></span><span>
</span><span id="line-26"></span><span>
</span><span id="line-27"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.Bag.html"><span class="hs-identifier">GHC.Data.Bag</span></a></span><span>
</span><span id="line-28"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html"><span class="hs-identifier">GHC.Types.Basic</span></a></span><span>
</span><span id="line-29"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Class.html"><span class="hs-identifier">GHC.Core.Class</span></a></span><span>
</span><span id="line-30"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html"><span class="hs-identifier">GHC.Core.DataCon</span></a></span><span>
</span><span id="line-31"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html"><span class="hs-identifier">GHC.Driver.Session</span></a></span><span>
</span><span id="line-32"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html"><span class="hs-identifier">GHC.Utils.Error</span></a></span><span>
</span><span id="line-33"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html"><span class="hs-identifier">GHC.Driver.Types</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Driver.Types.html#lookupFixity"><span class="hs-identifier">lookupFixity</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Driver.Types.html#mi_fix"><span class="hs-identifier">mi_fix</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-34"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Hs.html"><span class="hs-identifier">GHC.Hs</span></a></span><span>
</span><span id="line-35"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Instantiate.html"><span class="hs-identifier">GHC.Tc.Utils.Instantiate</span></a></span><span>
</span><span id="line-36"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.InstEnv.html"><span class="hs-identifier">GHC.Core.InstEnv</span></a></span><span>
</span><span id="line-37"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Iface.Load.html"><span class="hs-identifier">GHC.Iface.Load</span></a></span><span>   </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Iface.Load.html#loadInterfaceForName"><span class="hs-identifier">loadInterfaceForName</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-38"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Unit.Module.html"><span class="hs-identifier">GHC.Unit.Module</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Unit.Module.html#getModule"><span class="hs-identifier">getModule</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-39"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Name.html"><span class="hs-identifier">GHC.Types.Name</span></a></span><span>
</span><span id="line-40"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html"><span class="hs-identifier">GHC.Utils.Outputable</span></a></span><span>
</span><span id="line-41"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Names.html"><span class="hs-identifier">GHC.Builtin.Names</span></a></span><span>
</span><span id="line-42"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html"><span class="hs-identifier">GHC.Types.SrcLoc</span></a></span><span>
</span><span id="line-43"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Generate.html"><span class="hs-identifier">GHC.Tc.Deriv.Generate</span></a></span><span>
</span><span id="line-44"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Functor.html"><span class="hs-identifier">GHC.Tc.Deriv.Functor</span></a></span><span>
</span><span id="line-45"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Generics.html"><span class="hs-identifier">GHC.Tc.Deriv.Generics</span></a></span><span>
</span><span id="line-46"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html"><span class="hs-identifier">GHC.Tc.Types.Origin</span></a></span><span>
</span><span id="line-47"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.Monad.html"><span class="hs-identifier">GHC.Tc.Utils.Monad</span></a></span><span>
</span><span id="line-48"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Tc.Utils.TcType.html"><span class="hs-identifier">GHC.Tc.Utils.TcType</span></a></span><span>
</span><span id="line-49"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Builtin.Names.TH.html"><span class="hs-identifier">GHC.Builtin.Names.TH</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Builtin.Names.TH.html#liftClassKey"><span class="hs-identifier">liftClassKey</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-50"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html"><span class="hs-identifier">GHC.Core.TyCon</span></a></span><span>
</span><span id="line-51"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Multiplicity.html"><span class="hs-identifier">GHC.Core.Multiplicity</span></a></span><span>
</span><span id="line-52"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Ppr.html"><span class="hs-identifier">GHC.Core.TyCo.Ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Ppr.html#pprSourceTyCon"><span class="hs-identifier">pprSourceTyCon</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-53"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Core.Type.html"><span class="hs-identifier">GHC.Core.Type</span></a></span><span>
</span><span id="line-54"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Utils.Misc.html"><span class="hs-identifier">GHC.Utils.Misc</span></a></span><span>
</span><span id="line-55"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Types.Var.Set.html"><span class="hs-identifier">GHC.Types.Var.Set</span></a></span><span>
</span><span id="line-56"></span><span>
</span><span id="line-57"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Reader.html#"><span class="hs-identifier">Control.Monad.Trans.Reader</span></a></span><span>
</span><span id="line-58"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.Maybe.html#"><span class="hs-identifier">Data.Maybe</span></a></span><span>
</span><span id="line-59"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../ghc-boot/src/GHC.LanguageExtensions.html#"><span class="hs-identifier">GHC.LanguageExtensions</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">LangExt</span></span><span>
</span><span id="line-60"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="GHC.Data.List.SetOps.html"><span class="hs-identifier">GHC.Data.List.SetOps</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Data.List.SetOps.html#assocMaybe"><span class="hs-identifier">assocMaybe</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-61"></span><span>
</span><span id="line-62"></span><span class="hs-comment">-- | To avoid having to manually plumb everything in 'DerivEnv' throughout</span><span>
</span><span id="line-63"></span><span class="hs-comment">-- various functions in &quot;GHC.Tc.Deriv&quot; and &quot;GHC.Tc.Deriv.Infer&quot;, we use 'DerivM', which</span><span>
</span><span id="line-64"></span><span class="hs-comment">-- is a simple reader around 'TcRn'.</span><span>
</span><span id="line-65"></span><span class="hs-keyword">type</span><span> </span><span id="DerivM"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivM"><span class="hs-identifier hs-var">DerivM</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="../../transformers/src/Control.Monad.Trans.Reader.html#ReaderT"><span class="hs-identifier hs-type">ReaderT</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivEnv"><span class="hs-identifier hs-type">DerivEnv</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcRn"><span class="hs-identifier hs-type">TcRn</span></a></span><span>
</span><span id="line-66"></span><span>
</span><span id="line-67"></span><span class="hs-comment">-- | Is GHC processing a standalone deriving declaration?</span><span>
</span><span id="line-68"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#isStandaloneDeriv"><span class="hs-identifier hs-type">isStandaloneDeriv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivM"><span class="hs-identifier hs-type">DerivM</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-69"></span><span id="isStandaloneDeriv"><span class="annot"><span class="annottext">isStandaloneDeriv :: DerivM Bool
</span><a href="GHC.Tc.Deriv.Utils.html#isStandaloneDeriv"><span class="hs-identifier hs-var hs-var">isStandaloneDeriv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(DerivEnv -&gt; Bool) -&gt; DerivM Bool
forall (m :: * -&gt; *) r a. Monad m =&gt; (r -&gt; a) -&gt; ReaderT r m a
</span><a href="../../transformers/src/Control.Monad.Trans.Reader.html#asks"><span class="hs-identifier hs-var">asks</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DerivContext -&gt; Bool
</span><a href="#local-6989586621681170231"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">(DerivContext -&gt; Bool)
-&gt; (DerivEnv -&gt; DerivContext) -&gt; DerivEnv -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">DerivEnv -&gt; DerivContext
</span><a href="GHC.Tc.Deriv.Utils.html#denv_ctxt"><span class="hs-identifier hs-var hs-var">denv_ctxt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-70"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-71"></span><span>    </span><span class="annot"><a href="#local-6989586621681170231"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivContext"><span class="hs-identifier hs-type">DerivContext</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-72"></span><span>    </span><span id="local-6989586621681170231"><span class="annot"><span class="annottext">go :: DerivContext -&gt; Bool
</span><a href="#local-6989586621681170231"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#InferContext"><span class="hs-identifier hs-type">InferContext</span></a></span><span> </span><span id="local-6989586621681170227"><span class="annot"><span class="annottext">Maybe SrcSpan
</span><a href="#local-6989586621681170227"><span class="hs-identifier hs-var">wildcard</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe SrcSpan -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe SrcSpan
</span><a href="#local-6989586621681170227"><span class="hs-identifier hs-var">wildcard</span></a></span><span>
</span><span id="line-73"></span><span>    </span><span class="annot"><a href="#local-6989586621681170231"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#SupplyContext"><span class="hs-identifier hs-type">SupplyContext</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-74"></span><span>
</span><span id="line-75"></span><span class="hs-comment">-- | Is GHC processing a standalone deriving declaration with an</span><span>
</span><span id="line-76"></span><span class="hs-comment">-- extra-constraints wildcard as the context?</span><span>
</span><span id="line-77"></span><span class="hs-comment">-- (e.g., @deriving instance _ =&gt; Eq (Foo a)@)</span><span>
</span><span id="line-78"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#isStandaloneWildcardDeriv"><span class="hs-identifier hs-type">isStandaloneWildcardDeriv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivM"><span class="hs-identifier hs-type">DerivM</span></a></span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-79"></span><span id="isStandaloneWildcardDeriv"><span class="annot"><span class="annottext">isStandaloneWildcardDeriv :: DerivM Bool
</span><a href="GHC.Tc.Deriv.Utils.html#isStandaloneWildcardDeriv"><span class="hs-identifier hs-var hs-var">isStandaloneWildcardDeriv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(DerivEnv -&gt; Bool) -&gt; DerivM Bool
forall (m :: * -&gt; *) r a. Monad m =&gt; (r -&gt; a) -&gt; ReaderT r m a
</span><a href="../../transformers/src/Control.Monad.Trans.Reader.html#asks"><span class="hs-identifier hs-var">asks</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DerivContext -&gt; Bool
</span><a href="#local-6989586621681170224"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="annot"><span class="annottext">(DerivContext -&gt; Bool)
-&gt; (DerivEnv -&gt; DerivContext) -&gt; DerivEnv -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">DerivEnv -&gt; DerivContext
</span><a href="GHC.Tc.Deriv.Utils.html#denv_ctxt"><span class="hs-identifier hs-var hs-var">denv_ctxt</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-80"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-81"></span><span>    </span><span class="annot"><a href="#local-6989586621681170224"><span class="hs-identifier hs-type">go</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivContext"><span class="hs-identifier hs-type">DerivContext</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-82"></span><span>    </span><span id="local-6989586621681170224"><span class="annot"><span class="annottext">go :: DerivContext -&gt; Bool
</span><a href="#local-6989586621681170224"><span class="hs-identifier hs-var hs-var">go</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#InferContext"><span class="hs-identifier hs-type">InferContext</span></a></span><span> </span><span id="local-6989586621681170223"><span class="annot"><span class="annottext">Maybe SrcSpan
</span><a href="#local-6989586621681170223"><span class="hs-identifier hs-var">wildcard</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe SrcSpan -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isJust"><span class="hs-identifier hs-var">isJust</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe SrcSpan
</span><a href="#local-6989586621681170223"><span class="hs-identifier hs-var">wildcard</span></a></span><span>
</span><span id="line-83"></span><span>    </span><span class="annot"><a href="#local-6989586621681170224"><span class="hs-identifier hs-var">go</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#SupplyContext"><span class="hs-identifier hs-type">SupplyContext</span></a></span><span> </span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-84"></span><span>
</span><span id="line-85"></span><span class="hs-comment">-- | @'mkDerivOrigin' wc@ returns 'StandAloneDerivOrigin' if @wc@ is 'True',</span><span>
</span><span id="line-86"></span><span class="hs-comment">-- and 'DerivClauseOrigin' if @wc@ is 'False'. Useful for error-reporting.</span><span>
</span><span id="line-87"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#mkDerivOrigin"><span class="hs-identifier hs-type">mkDerivOrigin</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span>
</span><span id="line-88"></span><span id="mkDerivOrigin"><span class="annot"><span class="annottext">mkDerivOrigin :: Bool -&gt; CtOrigin
</span><a href="GHC.Tc.Deriv.Utils.html#mkDerivOrigin"><span class="hs-identifier hs-var hs-var">mkDerivOrigin</span></a></span></span><span> </span><span id="local-6989586621681170222"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681170222"><span class="hs-identifier hs-var">standalone_wildcard</span></a></span></span><span>
</span><span id="line-89"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681170222"><span class="hs-identifier hs-var">standalone_wildcard</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#StandAloneDerivOrigin"><span class="hs-identifier hs-var">StandAloneDerivOrigin</span></a></span><span>
</span><span id="line-90"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="GHC.Tc.Types.Origin.html#DerivClauseOrigin"><span class="hs-identifier hs-var">DerivClauseOrigin</span></a></span><span>
</span><span id="line-91"></span><span>
</span><span id="line-92"></span><span class="hs-comment">-- | Contains all of the information known about a derived instance when</span><span>
</span><span id="line-93"></span><span class="hs-comment">-- determining what its @EarlyDerivSpec@ should be.</span><span>
</span><span id="line-94"></span><span class="hs-comment">-- See @Note [DerivEnv and DerivSpecMechanism]@.</span><span>
</span><span id="line-95"></span><span class="hs-keyword">data</span><span> </span><span id="DerivEnv"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivEnv"><span class="hs-identifier hs-var">DerivEnv</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="DerivEnv"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivEnv"><span class="hs-identifier hs-var">DerivEnv</span></a></span></span><span>
</span><span id="line-96"></span><span>  </span><span class="hs-special">{</span><span> </span><span id="denv_overlap_mode"><span class="annot"><span class="annottext">DerivEnv -&gt; Maybe OverlapMode
</span><a href="GHC.Tc.Deriv.Utils.html#denv_overlap_mode"><span class="hs-identifier hs-var hs-var">denv_overlap_mode</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#OverlapMode"><span class="hs-identifier hs-type">OverlapMode</span></a></span><span>
</span><span id="line-97"></span><span>    </span><span class="hs-comment">-- ^ Is this an overlapping instance?</span><span>
</span><span id="line-98"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="denv_tvs"><span class="annot"><span class="annottext">DerivEnv -&gt; [TyVar]
</span><a href="GHC.Tc.Deriv.Utils.html#denv_tvs"><span class="hs-identifier hs-var hs-var">denv_tvs</span></a></span></span><span>          </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-99"></span><span>    </span><span class="hs-comment">-- ^ Universally quantified type variables in the instance</span><span>
</span><span id="line-100"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="denv_cls"><span class="annot"><span class="annottext">DerivEnv -&gt; Class
</span><a href="GHC.Tc.Deriv.Utils.html#denv_cls"><span class="hs-identifier hs-var hs-var">denv_cls</span></a></span></span><span>          </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span>
</span><span id="line-101"></span><span>    </span><span class="hs-comment">-- ^ Class for which we need to derive an instance</span><span>
</span><span id="line-102"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="denv_inst_tys"><span class="annot"><span class="annottext">DerivEnv -&gt; [Type]
</span><a href="GHC.Tc.Deriv.Utils.html#denv_inst_tys"><span class="hs-identifier hs-var hs-var">denv_inst_tys</span></a></span></span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-103"></span><span>    </span><span class="hs-comment">-- ^ All arguments to 'denv_cls' in the derived instance.</span><span>
</span><span id="line-104"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="denv_ctxt"><span class="annot"><span class="annottext">DerivEnv -&gt; DerivContext
</span><a href="GHC.Tc.Deriv.Utils.html#denv_ctxt"><span class="hs-identifier hs-var hs-var">denv_ctxt</span></a></span></span><span>         </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivContext"><span class="hs-identifier hs-type">DerivContext</span></a></span><span>
</span><span id="line-105"></span><span>    </span><span class="hs-comment">-- ^ @'SupplyContext' theta@ for standalone deriving (where @theta@ is the</span><span>
</span><span id="line-106"></span><span>    </span><span class="hs-comment">--   context of the instance).</span><span>
</span><span id="line-107"></span><span>    </span><span class="hs-comment">--   'InferContext' for @deriving@ clauses, or for standalone deriving that</span><span>
</span><span id="line-108"></span><span>    </span><span class="hs-comment">--   uses a wildcard constraint.</span><span>
</span><span id="line-109"></span><span>    </span><span class="hs-comment">--   See @Note [Inferring the instance context]@.</span><span>
</span><span id="line-110"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="denv_strat"><span class="annot"><span class="annottext">DerivEnv -&gt; Maybe (DerivStrategy GhcTc)
</span><a href="GHC.Tc.Deriv.Utils.html#denv_strat"><span class="hs-identifier hs-var hs-var">denv_strat</span></a></span></span><span>        </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Decls.html#DerivStrategy"><span class="hs-identifier hs-type">DerivStrategy</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-111"></span><span>    </span><span class="hs-comment">-- ^ 'Just' if user requests a particular deriving strategy.</span><span>
</span><span id="line-112"></span><span>    </span><span class="hs-comment">--   Otherwise, 'Nothing'.</span><span>
</span><span id="line-113"></span><span>  </span><span class="hs-special">}</span><span>
</span><span id="line-114"></span><span>
</span><span id="line-115"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681170211"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivEnv"><span class="hs-identifier hs-type">DerivEnv</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-116"></span><span>  </span><span id="local-6989586621681170188"><span class="annot"><span class="annottext">ppr :: DerivEnv -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivEnv"><span class="hs-identifier hs-type">DerivEnv</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">denv_overlap_mode :: DerivEnv -&gt; Maybe OverlapMode
</span><a href="GHC.Tc.Deriv.Utils.html#denv_overlap_mode"><span class="hs-identifier hs-var">denv_overlap_mode</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170186"><span class="annot"><span class="annottext">Maybe OverlapMode
</span><a href="#local-6989586621681170186"><span class="hs-identifier hs-var">overlap_mode</span></a></span></span><span>
</span><span id="line-117"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">denv_tvs :: DerivEnv -&gt; [TyVar]
</span><a href="GHC.Tc.Deriv.Utils.html#denv_tvs"><span class="hs-identifier hs-var">denv_tvs</span></a></span><span>          </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170185"><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681170185"><span class="hs-identifier hs-var">tvs</span></a></span></span><span>
</span><span id="line-118"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">denv_cls :: DerivEnv -&gt; Class
</span><a href="GHC.Tc.Deriv.Utils.html#denv_cls"><span class="hs-identifier hs-var">denv_cls</span></a></span><span>          </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170184"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681170184"><span class="hs-identifier hs-var">cls</span></a></span></span><span>
</span><span id="line-119"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">denv_inst_tys :: DerivEnv -&gt; [Type]
</span><a href="GHC.Tc.Deriv.Utils.html#denv_inst_tys"><span class="hs-identifier hs-var">denv_inst_tys</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170183"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681170183"><span class="hs-identifier hs-var">inst_tys</span></a></span></span><span>
</span><span id="line-120"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">denv_ctxt :: DerivEnv -&gt; DerivContext
</span><a href="GHC.Tc.Deriv.Utils.html#denv_ctxt"><span class="hs-identifier hs-var">denv_ctxt</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170182"><span class="annot"><span class="annottext">DerivContext
</span><a href="#local-6989586621681170182"><span class="hs-identifier hs-var">ctxt</span></a></span></span><span>
</span><span id="line-121"></span><span>                </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">denv_strat :: DerivEnv -&gt; Maybe (DerivStrategy GhcTc)
</span><a href="GHC.Tc.Deriv.Utils.html#denv_strat"><span class="hs-identifier hs-var">denv_strat</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170181"><span class="annot"><span class="annottext">Maybe (DerivStrategy GhcTc)
</span><a href="#local-6989586621681170181"><span class="hs-identifier hs-var">mb_strat</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-122"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;DerivEnv&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-123"></span><span>         </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;denv_overlap_mode&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe OverlapMode -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe OverlapMode
</span><a href="#local-6989586621681170186"><span class="hs-identifier hs-var">overlap_mode</span></a></span><span>
</span><span id="line-124"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;denv_tvs&quot;</span></span><span>          </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681170185"><span class="hs-identifier hs-var">tvs</span></a></span><span>
</span><span id="line-125"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;denv_cls&quot;</span></span><span>          </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Class -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681170184"><span class="hs-identifier hs-var">cls</span></a></span><span>
</span><span id="line-126"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;denv_inst_tys&quot;</span></span><span>     </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681170183"><span class="hs-identifier hs-var">inst_tys</span></a></span><span>
</span><span id="line-127"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;denv_ctxt&quot;</span></span><span>         </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">DerivContext -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">DerivContext
</span><a href="#local-6989586621681170182"><span class="hs-identifier hs-var">ctxt</span></a></span><span>
</span><span id="line-128"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;denv_strat&quot;</span></span><span>        </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (DerivStrategy GhcTc) -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe (DerivStrategy GhcTc)
</span><a href="#local-6989586621681170181"><span class="hs-identifier hs-var">mb_strat</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-129"></span><span>
</span><span id="line-130"></span><span class="hs-keyword">data</span><span> </span><span id="DerivSpec"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpec"><span class="hs-identifier hs-var">DerivSpec</span></a></span></span><span> </span><span id="local-6989586621681170482"><span class="annot"><a href="#local-6989586621681170482"><span class="hs-identifier hs-type">theta</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="DS"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DS"><span class="hs-identifier hs-var">DS</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="ds_loc"><span class="annot"><span class="annottext">forall theta. DerivSpec theta -&gt; SrcSpan
</span><a href="GHC.Tc.Deriv.Utils.html#ds_loc"><span class="hs-identifier hs-var hs-var">ds_loc</span></a></span></span><span>                 </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#SrcSpan"><span class="hs-identifier hs-type">SrcSpan</span></a></span><span>
</span><span id="line-131"></span><span>                          </span><span class="hs-special">,</span><span> </span><span id="ds_name"><span class="annot"><span class="annottext">forall theta. DerivSpec theta -&gt; Name
</span><a href="GHC.Tc.Deriv.Utils.html#ds_name"><span class="hs-identifier hs-var hs-var">ds_name</span></a></span></span><span>                </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span>         </span><span class="hs-comment">-- DFun name</span><span>
</span><span id="line-132"></span><span>                          </span><span class="hs-special">,</span><span> </span><span id="ds_tvs"><span class="annot"><span class="annottext">forall theta. DerivSpec theta -&gt; [TyVar]
</span><a href="GHC.Tc.Deriv.Utils.html#ds_tvs"><span class="hs-identifier hs-var hs-var">ds_tvs</span></a></span></span><span>                 </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-133"></span><span>                          </span><span class="hs-special">,</span><span> </span><span id="ds_theta"><span class="annot"><span class="annottext">forall theta. DerivSpec theta -&gt; theta
</span><a href="GHC.Tc.Deriv.Utils.html#ds_theta"><span class="hs-identifier hs-var hs-var">ds_theta</span></a></span></span><span>               </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="#local-6989586621681170482"><span class="hs-identifier hs-type">theta</span></a></span><span>
</span><span id="line-134"></span><span>                          </span><span class="hs-special">,</span><span> </span><span id="ds_cls"><span class="annot"><span class="annottext">forall theta. DerivSpec theta -&gt; Class
</span><a href="GHC.Tc.Deriv.Utils.html#ds_cls"><span class="hs-identifier hs-var hs-var">ds_cls</span></a></span></span><span>                 </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span>
</span><span id="line-135"></span><span>                          </span><span class="hs-special">,</span><span> </span><span id="ds_tys"><span class="annot"><span class="annottext">forall theta. DerivSpec theta -&gt; [Type]
</span><a href="GHC.Tc.Deriv.Utils.html#ds_tys"><span class="hs-identifier hs-var hs-var">ds_tys</span></a></span></span><span>                 </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-136"></span><span>                          </span><span class="hs-special">,</span><span> </span><span id="ds_overlap"><span class="annot"><span class="annottext">forall theta. DerivSpec theta -&gt; Maybe OverlapMode
</span><a href="GHC.Tc.Deriv.Utils.html#ds_overlap"><span class="hs-identifier hs-var hs-var">ds_overlap</span></a></span></span><span>             </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#OverlapMode"><span class="hs-identifier hs-type">OverlapMode</span></a></span><span>
</span><span id="line-137"></span><span>                          </span><span class="hs-special">,</span><span> </span><span id="ds_standalone_wildcard"><span class="annot"><span class="annottext">forall theta. DerivSpec theta -&gt; Maybe SrcSpan
</span><a href="GHC.Tc.Deriv.Utils.html#ds_standalone_wildcard"><span class="hs-identifier hs-var hs-var">ds_standalone_wildcard</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#SrcSpan"><span class="hs-identifier hs-type">SrcSpan</span></a></span><span>
</span><span id="line-138"></span><span>                              </span><span class="hs-comment">-- See Note [Inferring the instance context]</span><span>
</span><span id="line-139"></span><span>                              </span><span class="hs-comment">-- in GHC.Tc.Deriv.Infer</span><span>
</span><span id="line-140"></span><span>                          </span><span class="hs-special">,</span><span> </span><span id="ds_mechanism"><span class="annot"><span class="annottext">forall theta. DerivSpec theta -&gt; DerivSpecMechanism
</span><a href="GHC.Tc.Deriv.Utils.html#ds_mechanism"><span class="hs-identifier hs-var hs-var">ds_mechanism</span></a></span></span><span>           </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpecMechanism"><span class="hs-identifier hs-type">DerivSpecMechanism</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-141"></span><span>        </span><span class="hs-comment">-- This spec implies a dfun declaration of the form</span><span>
</span><span id="line-142"></span><span>        </span><span class="hs-comment">--       df :: forall tvs. theta =&gt; C tys</span><span>
</span><span id="line-143"></span><span>        </span><span class="hs-comment">-- The Name is the name for the DFun we'll build</span><span>
</span><span id="line-144"></span><span>        </span><span class="hs-comment">-- The tyvars bind all the variables in the theta</span><span>
</span><span id="line-145"></span><span>
</span><span id="line-146"></span><span>        </span><span class="hs-comment">-- the theta is either the given and final theta, in standalone deriving,</span><span>
</span><span id="line-147"></span><span>        </span><span class="hs-comment">-- or the not-yet-simplified list of constraints together with their origin</span><span>
</span><span id="line-148"></span><span>
</span><span id="line-149"></span><span>        </span><span class="hs-comment">-- ds_mechanism specifies the means by which GHC derives the instance.</span><span>
</span><span id="line-150"></span><span>        </span><span class="hs-comment">-- See Note [Deriving strategies] in GHC.Tc.Deriv</span><span>
</span><span id="line-151"></span><span>
</span><span id="line-152"></span><span class="hs-comment">{-
Example:

     newtype instance T [a] = MkT (Tree a) deriving( C s )
==&gt;
     axiom T [a] = :RTList a
     axiom :RTList a = Tree a

     DS { ds_tvs = [a,s], ds_cls = C, ds_tys = [s, T [a]]
        , ds_mechanism = DerivSpecNewtype (Tree a) }
-}</span><span>
</span><span id="line-163"></span><span>
</span><span id="line-164"></span><span id="local-6989586621681170472"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#pprDerivSpec"><span class="hs-identifier hs-type">pprDerivSpec</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681170472"><span class="hs-identifier hs-type">theta</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpec"><span class="hs-identifier hs-type">DerivSpec</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681170472"><span class="hs-identifier hs-type">theta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span></span><span>
</span><span id="line-165"></span><span id="pprDerivSpec"><span class="annot"><span class="annottext">pprDerivSpec :: forall theta. Outputable theta =&gt; DerivSpec theta -&gt; SDoc
</span><a href="GHC.Tc.Deriv.Utils.html#pprDerivSpec"><span class="hs-identifier hs-var hs-var">pprDerivSpec</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DS"><span class="hs-identifier hs-type">DS</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ds_loc :: forall theta. DerivSpec theta -&gt; SrcSpan
</span><a href="GHC.Tc.Deriv.Utils.html#ds_loc"><span class="hs-identifier hs-var">ds_loc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170155"><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681170155"><span class="hs-identifier hs-var">l</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ds_name :: forall theta. DerivSpec theta -&gt; Name
</span><a href="GHC.Tc.Deriv.Utils.html#ds_name"><span class="hs-identifier hs-var">ds_name</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170154"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681170154"><span class="hs-identifier hs-var">n</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ds_tvs :: forall theta. DerivSpec theta -&gt; [TyVar]
</span><a href="GHC.Tc.Deriv.Utils.html#ds_tvs"><span class="hs-identifier hs-var">ds_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170153"><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681170153"><span class="hs-identifier hs-var">tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ds_cls :: forall theta. DerivSpec theta -&gt; Class
</span><a href="GHC.Tc.Deriv.Utils.html#ds_cls"><span class="hs-identifier hs-var">ds_cls</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170152"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681170152"><span class="hs-identifier hs-var">c</span></a></span></span><span class="hs-special">,</span><span>
</span><span id="line-166"></span><span>                   </span><span class="annot"><span class="annottext">ds_tys :: forall theta. DerivSpec theta -&gt; [Type]
</span><a href="GHC.Tc.Deriv.Utils.html#ds_tys"><span class="hs-identifier hs-var">ds_tys</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170151"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681170151"><span class="hs-identifier hs-var">tys</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ds_theta :: forall theta. DerivSpec theta -&gt; theta
</span><a href="GHC.Tc.Deriv.Utils.html#ds_theta"><span class="hs-identifier hs-var">ds_theta</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170150"><span class="annot"><span class="annottext">theta
</span><a href="#local-6989586621681170150"><span class="hs-identifier hs-var">rhs</span></a></span></span><span class="hs-special">,</span><span>
</span><span id="line-167"></span><span>                   </span><span class="annot"><span class="annottext">ds_standalone_wildcard :: forall theta. DerivSpec theta -&gt; Maybe SrcSpan
</span><a href="GHC.Tc.Deriv.Utils.html#ds_standalone_wildcard"><span class="hs-identifier hs-var">ds_standalone_wildcard</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170149"><span class="annot"><span class="annottext">Maybe SrcSpan
</span><a href="#local-6989586621681170149"><span class="hs-identifier hs-var">wildcard</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ds_mechanism :: forall theta. DerivSpec theta -&gt; DerivSpecMechanism
</span><a href="GHC.Tc.Deriv.Utils.html#ds_mechanism"><span class="hs-identifier hs-var">ds_mechanism</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170148"><span class="annot"><span class="annottext">DerivSpecMechanism
</span><a href="#local-6989586621681170148"><span class="hs-identifier hs-var">mech</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-168"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;DerivSpec&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-169"></span><span>       </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ds_loc                  =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
</span><a href="#local-6989586621681170155"><span class="hs-identifier hs-var">l</span></a></span><span>
</span><span id="line-170"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ds_name                 =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681170154"><span class="hs-identifier hs-var">n</span></a></span><span>
</span><span id="line-171"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ds_tvs                  =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681170153"><span class="hs-identifier hs-var">tvs</span></a></span><span>
</span><span id="line-172"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ds_cls                  =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Class -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681170152"><span class="hs-identifier hs-var">c</span></a></span><span>
</span><span id="line-173"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ds_tys                  =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681170151"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-174"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ds_theta                =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">theta -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">theta
</span><a href="#local-6989586621681170150"><span class="hs-identifier hs-var">rhs</span></a></span><span>
</span><span id="line-175"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ds_standalone_wildcard  =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe SrcSpan -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe SrcSpan
</span><a href="#local-6989586621681170149"><span class="hs-identifier hs-var">wildcard</span></a></span><span>
</span><span id="line-176"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ds_mechanism            =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">DerivSpecMechanism -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">DerivSpecMechanism
</span><a href="#local-6989586621681170148"><span class="hs-identifier hs-var">mech</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-177"></span><span>
</span><span id="line-178"></span><span id="local-6989586621681170470"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681170145"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681170470"><span class="hs-identifier hs-type">theta</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpec"><span class="hs-identifier hs-type">DerivSpec</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681170470"><span class="hs-identifier hs-type">theta</span></a></span><span class="hs-special">)</span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-179"></span><span>  </span><span id="local-6989586621681170143"><span class="annot"><span class="annottext">ppr :: DerivSpec theta -&gt; SDoc
</span><a href="#local-6989586621681170143"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DerivSpec theta -&gt; SDoc
forall theta. Outputable theta =&gt; DerivSpec theta -&gt; SDoc
</span><a href="GHC.Tc.Deriv.Utils.html#pprDerivSpec"><span class="hs-identifier hs-var">pprDerivSpec</span></a></span></span><span>
</span><span id="line-180"></span><span>
</span><span id="line-181"></span><span class="hs-comment">-- | Information about the arguments to the class in a stock- or</span><span>
</span><span id="line-182"></span><span class="hs-comment">-- newtype-derived instance.</span><span>
</span><span id="line-183"></span><span class="hs-comment">-- See @Note [DerivEnv and DerivSpecMechanism]@.</span><span>
</span><span id="line-184"></span><span class="hs-keyword">data</span><span> </span><span id="DerivInstTys"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivInstTys"><span class="hs-identifier hs-var">DerivInstTys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="DerivInstTys"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivInstTys"><span class="hs-identifier hs-var">DerivInstTys</span></a></span></span><span>
</span><span id="line-185"></span><span>  </span><span class="hs-special">{</span><span> </span><span id="dit_cls_tys"><span class="annot"><span class="annottext">DerivInstTys -&gt; [Type]
</span><a href="GHC.Tc.Deriv.Utils.html#dit_cls_tys"><span class="hs-identifier hs-var hs-var">dit_cls_tys</span></a></span></span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-186"></span><span>    </span><span class="hs-comment">-- ^ Other arguments to the class except the last</span><span>
</span><span id="line-187"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="dit_tc"><span class="annot"><span class="annottext">DerivInstTys -&gt; TyCon
</span><a href="GHC.Tc.Deriv.Utils.html#dit_tc"><span class="hs-identifier hs-var hs-var">dit_tc</span></a></span></span><span>          </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span>
</span><span id="line-188"></span><span>    </span><span class="hs-comment">-- ^ Type constructor for which the instance is requested</span><span>
</span><span id="line-189"></span><span>    </span><span class="hs-comment">--   (last arguments to the type class)</span><span>
</span><span id="line-190"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="dit_tc_args"><span class="annot"><span class="annottext">DerivInstTys -&gt; [Type]
</span><a href="GHC.Tc.Deriv.Utils.html#dit_tc_args"><span class="hs-identifier hs-var hs-var">dit_tc_args</span></a></span></span><span>     </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-191"></span><span>    </span><span class="hs-comment">-- ^ Arguments to the type constructor</span><span>
</span><span id="line-192"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="dit_rep_tc"><span class="annot"><span class="annottext">DerivInstTys -&gt; TyCon
</span><a href="GHC.Tc.Deriv.Utils.html#dit_rep_tc"><span class="hs-identifier hs-var hs-var">dit_rep_tc</span></a></span></span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span>
</span><span id="line-193"></span><span>    </span><span class="hs-comment">-- ^ The representation tycon for 'dit_tc'</span><span>
</span><span id="line-194"></span><span>    </span><span class="hs-comment">--   (for data family instances). Otherwise the same as 'dit_tc'.</span><span>
</span><span id="line-195"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="dit_rep_tc_args"><span class="annot"><span class="annottext">DerivInstTys -&gt; [Type]
</span><a href="GHC.Tc.Deriv.Utils.html#dit_rep_tc_args"><span class="hs-identifier hs-var hs-var">dit_rep_tc_args</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-196"></span><span>    </span><span class="hs-comment">-- ^ The representation types for 'dit_tc_args'</span><span>
</span><span id="line-197"></span><span>    </span><span class="hs-comment">--   (for data family instances). Otherwise the same as 'dit_tc_args'.</span><span>
</span><span id="line-198"></span><span>  </span><span class="hs-special">}</span><span>
</span><span id="line-199"></span><span>
</span><span id="line-200"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681170134"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivInstTys"><span class="hs-identifier hs-type">DerivInstTys</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-201"></span><span>  </span><span id="local-6989586621681170128"><span class="annot"><span class="annottext">ppr :: DerivInstTys -&gt; SDoc
</span><a href="#local-6989586621681170128"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivInstTys"><span class="hs-identifier hs-type">DerivInstTys</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dit_cls_tys :: DerivInstTys -&gt; [Type]
</span><a href="GHC.Tc.Deriv.Utils.html#dit_cls_tys"><span class="hs-identifier hs-var">dit_cls_tys</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170127"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681170127"><span class="hs-identifier hs-var">cls_tys</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dit_tc :: DerivInstTys -&gt; TyCon
</span><a href="GHC.Tc.Deriv.Utils.html#dit_tc"><span class="hs-identifier hs-var">dit_tc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170126"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681170126"><span class="hs-identifier hs-var">tc</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dit_tc_args :: DerivInstTys -&gt; [Type]
</span><a href="GHC.Tc.Deriv.Utils.html#dit_tc_args"><span class="hs-identifier hs-var">dit_tc_args</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170125"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681170125"><span class="hs-identifier hs-var">tc_args</span></a></span></span><span>
</span><span id="line-202"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dit_rep_tc :: DerivInstTys -&gt; TyCon
</span><a href="GHC.Tc.Deriv.Utils.html#dit_rep_tc"><span class="hs-identifier hs-var">dit_rep_tc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170124"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681170124"><span class="hs-identifier hs-var">rep_tc</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dit_rep_tc_args :: DerivInstTys -&gt; [Type]
</span><a href="GHC.Tc.Deriv.Utils.html#dit_rep_tc_args"><span class="hs-identifier hs-var">dit_rep_tc_args</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170123"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681170123"><span class="hs-identifier hs-var">rep_tc_args</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-203"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;DITTyConHead&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-204"></span><span>         </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;dit_cls_tys&quot;</span></span><span>     </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681170127"><span class="hs-identifier hs-var">cls_tys</span></a></span><span>
</span><span id="line-205"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;dit_tc&quot;</span></span><span>          </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681170126"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-206"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;dit_tc_args&quot;</span></span><span>     </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681170125"><span class="hs-identifier hs-var">tc_args</span></a></span><span>
</span><span id="line-207"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;dit_rep_tc&quot;</span></span><span>      </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681170124"><span class="hs-identifier hs-var">rep_tc</span></a></span><span>
</span><span id="line-208"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;dit_rep_tc_args&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681170123"><span class="hs-identifier hs-var">rep_tc_args</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-209"></span><span>
</span><span id="line-210"></span><span class="hs-comment">-- | What action to take in order to derive a class instance.</span><span>
</span><span id="line-211"></span><span class="hs-comment">-- See @Note [DerivEnv and DerivSpecMechanism]@, as well as</span><span>
</span><span id="line-212"></span><span class="hs-comment">-- @Note [Deriving strategies]@ in &quot;GHC.Tc.Deriv&quot;.</span><span>
</span><span id="line-213"></span><span class="hs-keyword">data</span><span> </span><span id="DerivSpecMechanism"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpecMechanism"><span class="hs-identifier hs-var">DerivSpecMechanism</span></a></span></span><span>
</span><span id="line-214"></span><span>    </span><span class="hs-comment">-- | \&quot;Standard\&quot; classes</span><span>
</span><span id="line-215"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="DerivSpecStock"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpecStock"><span class="hs-identifier hs-var">DerivSpecStock</span></a></span></span><span>
</span><span id="line-216"></span><span>    </span><span class="hs-special">{</span><span> </span><span id="dsm_stock_dit"><span class="annot"><span class="annottext">DerivSpecMechanism -&gt; DerivInstTys
</span><a href="GHC.Tc.Deriv.Utils.html#dsm_stock_dit"><span class="hs-identifier hs-var hs-var">dsm_stock_dit</span></a></span></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivInstTys"><span class="hs-identifier hs-type">DerivInstTys</span></a></span><span>
</span><span id="line-217"></span><span>      </span><span class="hs-comment">-- ^ Information about the arguments to the class in the derived</span><span>
</span><span id="line-218"></span><span>      </span><span class="hs-comment">-- instance, including what type constructor the last argument is</span><span>
</span><span id="line-219"></span><span>      </span><span class="hs-comment">-- headed by. See @Note [DerivEnv and DerivSpecMechanism]@.</span><span>
</span><span id="line-220"></span><span>    </span><span class="hs-special">,</span><span> </span><span id="dsm_stock_gen_fn"><span class="annot"><span class="annottext">DerivSpecMechanism
-&gt; SrcSpan
-&gt; TyCon
-&gt; [Type]
-&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name])
</span><a href="GHC.Tc.Deriv.Utils.html#dsm_stock_gen_fn"><span class="hs-identifier hs-var hs-var">dsm_stock_gen_fn</span></a></span></span><span> </span><span class="hs-glyph">::</span><span>
</span><span id="line-221"></span><span>        </span><span class="annot"><a href="GHC.Types.SrcLoc.html#SrcSpan"><span class="hs-identifier hs-type">SrcSpan</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span>
</span><span id="line-222"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-223"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBinds"><span class="hs-identifier hs-type">LHsBinds</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcPs"><span class="hs-identifier hs-type">GhcPs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Generate.html#BagDerivStuff"><span class="hs-identifier hs-type">BagDerivStuff</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-224"></span><span>      </span><span class="hs-comment">-- ^ This function returns three things:</span><span>
</span><span id="line-225"></span><span>      </span><span class="hs-comment">--</span><span>
</span><span id="line-226"></span><span>      </span><span class="hs-comment">-- 1. @LHsBinds GhcPs@: The derived instance's function bindings</span><span>
</span><span id="line-227"></span><span>      </span><span class="hs-comment">--    (e.g., @compare (T x) (T y) = compare x y@)</span><span>
</span><span id="line-228"></span><span>      </span><span class="hs-comment">--</span><span>
</span><span id="line-229"></span><span>      </span><span class="hs-comment">-- 2. @BagDerivStuff@: Auxiliary bindings needed to support the derived</span><span>
</span><span id="line-230"></span><span>      </span><span class="hs-comment">--    instance. As examples, derived 'Generic' instances require</span><span>
</span><span id="line-231"></span><span>      </span><span class="hs-comment">--    associated type family instances, and derived 'Eq' and 'Ord'</span><span>
</span><span id="line-232"></span><span>      </span><span class="hs-comment">--    instances require top-level @con2tag@ functions.</span><span>
</span><span id="line-233"></span><span>      </span><span class="hs-comment">--    See @Note [Auxiliary binders]@ in &quot;GHC.Tc.Deriv.Generate&quot;.</span><span>
</span><span id="line-234"></span><span>      </span><span class="hs-comment">--</span><span>
</span><span id="line-235"></span><span>      </span><span class="hs-comment">-- 3. @[Name]@: A list of Names for which @-Wunused-binds@ should be</span><span>
</span><span id="line-236"></span><span>      </span><span class="hs-comment">--    suppressed. This is used to suppress unused warnings for record</span><span>
</span><span id="line-237"></span><span>      </span><span class="hs-comment">--    selectors when deriving 'Read', 'Show', or 'Generic'.</span><span>
</span><span id="line-238"></span><span>      </span><span class="hs-comment">--    See @Note [Deriving and unused record selectors]@.</span><span>
</span><span id="line-239"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-240"></span><span>
</span><span id="line-241"></span><span>    </span><span class="hs-comment">-- | @GeneralizedNewtypeDeriving@</span><span>
</span><span id="line-242"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="DerivSpecNewtype"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpecNewtype"><span class="hs-identifier hs-var">DerivSpecNewtype</span></a></span></span><span>
</span><span id="line-243"></span><span>    </span><span class="hs-special">{</span><span> </span><span id="dsm_newtype_dit"><span class="annot"><span class="annottext">DerivSpecMechanism -&gt; DerivInstTys
</span><a href="GHC.Tc.Deriv.Utils.html#dsm_newtype_dit"><span class="hs-identifier hs-var hs-var">dsm_newtype_dit</span></a></span></span><span>    </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivInstTys"><span class="hs-identifier hs-type">DerivInstTys</span></a></span><span>
</span><span id="line-244"></span><span>      </span><span class="hs-comment">-- ^ Information about the arguments to the class in the derived</span><span>
</span><span id="line-245"></span><span>      </span><span class="hs-comment">-- instance, including what type constructor the last argument is</span><span>
</span><span id="line-246"></span><span>      </span><span class="hs-comment">-- headed by. See @Note [DerivEnv and DerivSpecMechanism]@.</span><span>
</span><span id="line-247"></span><span>    </span><span class="hs-special">,</span><span> </span><span id="dsm_newtype_rep_ty"><span class="annot"><span class="annottext">DerivSpecMechanism -&gt; Type
</span><a href="GHC.Tc.Deriv.Utils.html#dsm_newtype_rep_ty"><span class="hs-identifier hs-var hs-var">dsm_newtype_rep_ty</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-248"></span><span>      </span><span class="hs-comment">-- ^ The newtype rep type.</span><span>
</span><span id="line-249"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-250"></span><span>
</span><span id="line-251"></span><span>    </span><span class="hs-comment">-- | @DeriveAnyClass@</span><span>
</span><span id="line-252"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="DerivSpecAnyClass"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpecAnyClass"><span class="hs-identifier hs-var">DerivSpecAnyClass</span></a></span></span><span>
</span><span id="line-253"></span><span>
</span><span id="line-254"></span><span>    </span><span class="hs-comment">-- | @DerivingVia@</span><span>
</span><span id="line-255"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="DerivSpecVia"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpecVia"><span class="hs-identifier hs-var">DerivSpecVia</span></a></span></span><span>
</span><span id="line-256"></span><span>    </span><span class="hs-special">{</span><span> </span><span id="dsm_via_cls_tys"><span class="annot"><span class="annottext">DerivSpecMechanism -&gt; [Type]
</span><a href="GHC.Tc.Deriv.Utils.html#dsm_via_cls_tys"><span class="hs-identifier hs-var hs-var">dsm_via_cls_tys</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-257"></span><span>      </span><span class="hs-comment">-- ^ All arguments to the class besides the last one.</span><span>
</span><span id="line-258"></span><span>    </span><span class="hs-special">,</span><span> </span><span id="dsm_via_inst_ty"><span class="annot"><span class="annottext">DerivSpecMechanism -&gt; Type
</span><a href="GHC.Tc.Deriv.Utils.html#dsm_via_inst_ty"><span class="hs-identifier hs-var hs-var">dsm_via_inst_ty</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-259"></span><span>      </span><span class="hs-comment">-- ^ The last argument to the class.</span><span>
</span><span id="line-260"></span><span>    </span><span class="hs-special">,</span><span> </span><span id="dsm_via_ty"><span class="annot"><span class="annottext">DerivSpecMechanism -&gt; Type
</span><a href="GHC.Tc.Deriv.Utils.html#dsm_via_ty"><span class="hs-identifier hs-var hs-var">dsm_via_ty</span></a></span></span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span>
</span><span id="line-261"></span><span>      </span><span class="hs-comment">-- ^ The @via@ type</span><span>
</span><span id="line-262"></span><span>    </span><span class="hs-special">}</span><span>
</span><span id="line-263"></span><span>
</span><span id="line-264"></span><span class="hs-comment">-- | Convert a 'DerivSpecMechanism' to its corresponding 'DerivStrategy'.</span><span>
</span><span id="line-265"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#derivSpecMechanismToStrategy"><span class="hs-identifier hs-type">derivSpecMechanismToStrategy</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpecMechanism"><span class="hs-identifier hs-type">DerivSpecMechanism</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Hs.Decls.html#DerivStrategy"><span class="hs-identifier hs-type">DerivStrategy</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcTc"><span class="hs-identifier hs-type">GhcTc</span></a></span><span>
</span><span id="line-266"></span><span id="derivSpecMechanismToStrategy"><span class="annot"><span class="annottext">derivSpecMechanismToStrategy :: DerivSpecMechanism -&gt; DerivStrategy GhcTc
</span><a href="GHC.Tc.Deriv.Utils.html#derivSpecMechanismToStrategy"><span class="hs-identifier hs-var hs-var">derivSpecMechanismToStrategy</span></a></span></span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpecStock"><span class="hs-identifier hs-type">DerivSpecStock</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span>               </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DerivStrategy GhcTc
forall pass. DerivStrategy pass
</span><a href="GHC.Hs.Decls.html#StockStrategy"><span class="hs-identifier hs-var">StockStrategy</span></a></span><span>
</span><span id="line-267"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#derivSpecMechanismToStrategy"><span class="hs-identifier hs-var">derivSpecMechanismToStrategy</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpecNewtype"><span class="hs-identifier hs-type">DerivSpecNewtype</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DerivStrategy GhcTc
forall pass. DerivStrategy pass
</span><a href="GHC.Hs.Decls.html#NewtypeStrategy"><span class="hs-identifier hs-var">NewtypeStrategy</span></a></span><span>
</span><span id="line-268"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#derivSpecMechanismToStrategy"><span class="hs-identifier hs-var">derivSpecMechanismToStrategy</span></a></span><span> </span><span class="annot"><span class="annottext">DerivSpecMechanism
</span><a href="GHC.Tc.Deriv.Utils.html#DerivSpecAnyClass"><span class="hs-identifier hs-var">DerivSpecAnyClass</span></a></span><span>              </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DerivStrategy GhcTc
forall pass. DerivStrategy pass
</span><a href="GHC.Hs.Decls.html#AnyclassStrategy"><span class="hs-identifier hs-var">AnyclassStrategy</span></a></span><span>
</span><span id="line-269"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#derivSpecMechanismToStrategy"><span class="hs-identifier hs-var">derivSpecMechanismToStrategy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpecVia"><span class="hs-identifier hs-type">DerivSpecVia</span></a></span><span class="hs-special">{</span><span class="annot"><span class="annottext">dsm_via_ty :: DerivSpecMechanism -&gt; Type
</span><a href="GHC.Tc.Deriv.Utils.html#dsm_via_ty"><span class="hs-identifier hs-var">dsm_via_ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170108"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681170108"><span class="hs-identifier hs-var">t</span></a></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">XViaStrategy GhcTc -&gt; DerivStrategy GhcTc
forall pass. XViaStrategy pass -&gt; DerivStrategy pass
</span><a href="GHC.Hs.Decls.html#ViaStrategy"><span class="hs-identifier hs-var">ViaStrategy</span></a></span><span> </span><span class="annot"><span class="annottext">Type
XViaStrategy GhcTc
</span><a href="#local-6989586621681170108"><span class="hs-identifier hs-var">t</span></a></span><span>
</span><span id="line-270"></span><span>
</span><span id="line-271"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#isDerivSpecStock"><span class="hs-identifier hs-type">isDerivSpecStock</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#isDerivSpecNewtype"><span class="hs-identifier hs-type">isDerivSpecNewtype</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#isDerivSpecAnyClass"><span class="hs-identifier hs-type">isDerivSpecAnyClass</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#isDerivSpecVia"><span class="hs-identifier hs-type">isDerivSpecVia</span></a></span><span>
</span><span id="line-272"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpecMechanism"><span class="hs-identifier hs-type">DerivSpecMechanism</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-273"></span><span id="isDerivSpecStock"><span class="annot"><span class="annottext">isDerivSpecStock :: DerivSpecMechanism -&gt; Bool
</span><a href="GHC.Tc.Deriv.Utils.html#isDerivSpecStock"><span class="hs-identifier hs-var hs-var">isDerivSpecStock</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpecStock"><span class="hs-identifier hs-type">DerivSpecStock</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-274"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#isDerivSpecStock"><span class="hs-identifier hs-var">isDerivSpecStock</span></a></span><span> </span><span class="annot"><span class="annottext">DerivSpecMechanism
</span><span class="hs-identifier">_</span></span><span>                  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-275"></span><span>
</span><span id="line-276"></span><span id="isDerivSpecNewtype"><span class="annot"><span class="annottext">isDerivSpecNewtype :: DerivSpecMechanism -&gt; Bool
</span><a href="GHC.Tc.Deriv.Utils.html#isDerivSpecNewtype"><span class="hs-identifier hs-var hs-var">isDerivSpecNewtype</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpecNewtype"><span class="hs-identifier hs-type">DerivSpecNewtype</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-277"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#isDerivSpecNewtype"><span class="hs-identifier hs-var">isDerivSpecNewtype</span></a></span><span> </span><span class="annot"><span class="annottext">DerivSpecMechanism
</span><span class="hs-identifier">_</span></span><span>                    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-278"></span><span>
</span><span id="line-279"></span><span id="isDerivSpecAnyClass"><span class="annot"><span class="annottext">isDerivSpecAnyClass :: DerivSpecMechanism -&gt; Bool
</span><a href="GHC.Tc.Deriv.Utils.html#isDerivSpecAnyClass"><span class="hs-identifier hs-var hs-var">isDerivSpecAnyClass</span></a></span></span><span> </span><span class="annot"><span class="annottext">DerivSpecMechanism
</span><a href="GHC.Tc.Deriv.Utils.html#DerivSpecAnyClass"><span class="hs-identifier hs-var">DerivSpecAnyClass</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-280"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#isDerivSpecAnyClass"><span class="hs-identifier hs-var">isDerivSpecAnyClass</span></a></span><span> </span><span class="annot"><span class="annottext">DerivSpecMechanism
</span><span class="hs-identifier">_</span></span><span>                 </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-281"></span><span>
</span><span id="line-282"></span><span id="isDerivSpecVia"><span class="annot"><span class="annottext">isDerivSpecVia :: DerivSpecMechanism -&gt; Bool
</span><a href="GHC.Tc.Deriv.Utils.html#isDerivSpecVia"><span class="hs-identifier hs-var hs-var">isDerivSpecVia</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpecVia"><span class="hs-identifier hs-type">DerivSpecVia</span></a></span><span class="hs-special">{</span><span class="hs-special">}</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-283"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#isDerivSpecVia"><span class="hs-identifier hs-var">isDerivSpecVia</span></a></span><span> </span><span class="annot"><span class="annottext">DerivSpecMechanism
</span><span class="hs-identifier">_</span></span><span>                </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-284"></span><span>
</span><span id="line-285"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681170104"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpecMechanism"><span class="hs-identifier hs-type">DerivSpecMechanism</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-286"></span><span>  </span><span id="local-6989586621681170097"><span class="annot"><span class="annottext">ppr :: DerivSpecMechanism -&gt; SDoc
</span><a href="#local-6989586621681170097"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpecStock"><span class="hs-identifier hs-type">DerivSpecStock</span></a></span><span class="hs-special">{</span><span class="annot"><span class="annottext">dsm_stock_dit :: DerivSpecMechanism -&gt; DerivInstTys
</span><a href="GHC.Tc.Deriv.Utils.html#dsm_stock_dit"><span class="hs-identifier hs-var">dsm_stock_dit</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170096"><span class="annot"><span class="annottext">DerivInstTys
</span><a href="#local-6989586621681170096"><span class="hs-identifier hs-var">dit</span></a></span></span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-287"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;DerivSpecStock&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-288"></span><span>         </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;dsm_stock_dit&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">DerivInstTys -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">DerivInstTys
</span><a href="#local-6989586621681170096"><span class="hs-identifier hs-var">dit</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-289"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpecNewtype"><span class="hs-identifier hs-type">DerivSpecNewtype</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dsm_newtype_dit :: DerivSpecMechanism -&gt; DerivInstTys
</span><a href="GHC.Tc.Deriv.Utils.html#dsm_newtype_dit"><span class="hs-identifier hs-var">dsm_newtype_dit</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170095"><span class="annot"><span class="annottext">DerivInstTys
</span><a href="#local-6989586621681170095"><span class="hs-identifier hs-var">dit</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dsm_newtype_rep_ty :: DerivSpecMechanism -&gt; Type
</span><a href="GHC.Tc.Deriv.Utils.html#dsm_newtype_rep_ty"><span class="hs-identifier hs-var">dsm_newtype_rep_ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170094"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681170094"><span class="hs-identifier hs-var">rep_ty</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-290"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;DerivSpecNewtype&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-291"></span><span>         </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;dsm_newtype_dit&quot;</span></span><span>    </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">DerivInstTys -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">DerivInstTys
</span><a href="#local-6989586621681170095"><span class="hs-identifier hs-var">dit</span></a></span><span>
</span><span id="line-292"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;dsm_newtype_rep_ty&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681170094"><span class="hs-identifier hs-var">rep_ty</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-293"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">DerivSpecMechanism
</span><a href="GHC.Tc.Deriv.Utils.html#DerivSpecAnyClass"><span class="hs-identifier hs-var">DerivSpecAnyClass</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;DerivSpecAnyClass&quot;</span></span><span>
</span><span id="line-294"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpecVia"><span class="hs-identifier hs-type">DerivSpecVia</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">dsm_via_cls_tys :: DerivSpecMechanism -&gt; [Type]
</span><a href="GHC.Tc.Deriv.Utils.html#dsm_via_cls_tys"><span class="hs-identifier hs-var">dsm_via_cls_tys</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170093"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681170093"><span class="hs-identifier hs-var">cls_tys</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dsm_via_inst_ty :: DerivSpecMechanism -&gt; Type
</span><a href="GHC.Tc.Deriv.Utils.html#dsm_via_inst_ty"><span class="hs-identifier hs-var">dsm_via_inst_ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170092"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681170092"><span class="hs-identifier hs-var">inst_ty</span></a></span></span><span>
</span><span id="line-295"></span><span>                    </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">dsm_via_ty :: DerivSpecMechanism -&gt; Type
</span><a href="GHC.Tc.Deriv.Utils.html#dsm_via_ty"><span class="hs-identifier hs-var">dsm_via_ty</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170091"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681170091"><span class="hs-identifier hs-var">via_ty</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-296"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;DerivSpecVia&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-297"></span><span>         </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;dsm_via_cls_tys&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681170093"><span class="hs-identifier hs-var">cls_tys</span></a></span><span>
</span><span id="line-298"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;dsm_via_inst_ty&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681170092"><span class="hs-identifier hs-var">inst_ty</span></a></span><span>
</span><span id="line-299"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;dsm_via_ty&quot;</span></span><span>      </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681170091"><span class="hs-identifier hs-var">via_ty</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-300"></span><span>
</span><span id="line-301"></span><span class="hs-comment">{-
Note [DerivEnv and DerivSpecMechanism]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
DerivEnv contains all of the bits and pieces that are common to every
deriving strategy. (See Note [Deriving strategies] in GHC.Tc.Deriv.) Some deriving
strategies impose stricter requirements on the types involved in the derived
instance than others, and these differences are factored out into the
DerivSpecMechanism type. Suppose that the derived instance looks like this:

  instance ... =&gt; C arg_1 ... arg_n

Each deriving strategy imposes restrictions on arg_1 through arg_n as follows:

* stock (DerivSpecStock):

  Stock deriving requires that:

  - n must be a positive number. This is checked by
    GHC.Tc.Deriv.expectNonNullaryClsArgs
  - arg_n must be an application of an algebraic type constructor. Here,
    &quot;algebraic type constructor&quot; means:

    + An ordinary data type constructor, or
    + A data family type constructor such that the arguments it is applied to
      give rise to a data family instance.

    This is checked by GHC.Tc.Deriv.expectAlgTyConApp.

  This extra structure is witnessed by the DerivInstTys data type, which stores
  arg_1 through arg_(n-1) (dit_cls_tys), the algebraic type constructor
  (dit_tc), and its arguments (dit_tc_args). If dit_tc is an ordinary data type
  constructor, then dit_rep_tc/dit_rep_tc_args are the same as
  dit_tc/dit_tc_args. If dit_tc is a data family type constructor, then
  dit_rep_tc is the representation type constructor for the data family
  instance, and dit_rep_tc_args are the arguments to the representation type
  constructor in the corresponding instance.

* newtype (DerivSpecNewtype):

  Newtype deriving imposes the same DerivInstTys requirements as stock
  deriving. This is necessary because we need to know what the underlying type
  that the newtype wraps is, and this information can only be learned by
  knowing dit_rep_tc.

* anyclass (DerivSpecAnyclass):

  DeriveAnyClass is the most permissive deriving strategy of all, as it
  essentially imposes no requirements on the derived instance. This is because
  DeriveAnyClass simply derives an empty instance, so it does not need any
  particular knowledge about the types involved. It can do several things
  that stock/newtype deriving cannot do (#13154):

  - n can be 0. That is, one is allowed to anyclass-derive an instance with
    no arguments to the class, such as in this example:

      class C
      deriving anyclass instance C

  - One can derive an instance for a type that is not headed by a type
    constructor, such as in the following example:

      class C (n :: Nat)
      deriving instance C 0
      deriving instance C 1
      ...

  - One can derive an instance for a data family with no data family instances,
    such as in the following example:

      data family Foo a
      class C a
      deriving anyclass instance C (Foo a)

* via (DerivSpecVia):

  Like newtype deriving, DerivingVia requires that n must be a positive number.
  This is because when one derives something like this:

    deriving via Foo instance C Bar

  Then the generated code must specifically mention Bar. However, in
  contrast with newtype deriving, DerivingVia does *not* require Bar to be
  an application of an algebraic type constructor. This is because the
  generated code simply defers to invoking `coerce`, which does not need to
  know anything in particular about Bar (besides that it is representationally
  equal to Foo). This allows DerivingVia to do some things that are not
  possible with newtype deriving, such as deriving instances for data families
  without data instances (#13154):

    data family Foo a
    newtype ByBar a = ByBar a
    class Baz a where ...
    instance Baz (ByBar a) where ...
    deriving via ByBar (Foo a) instance Baz (Foo a)
-}</span><span>
</span><span id="line-396"></span><span>
</span><span id="line-397"></span><span class="hs-comment">-- | Whether GHC is processing a @deriving@ clause or a standalone deriving</span><span>
</span><span id="line-398"></span><span class="hs-comment">-- declaration.</span><span>
</span><span id="line-399"></span><span class="hs-keyword">data</span><span> </span><span id="DerivContext"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivContext"><span class="hs-identifier hs-var">DerivContext</span></a></span></span><span>
</span><span id="line-400"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="InferContext"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#InferContext"><span class="hs-identifier hs-var">InferContext</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#SrcSpan"><span class="hs-identifier hs-type">SrcSpan</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- ^ @'InferContext mb_wildcard@ is either:</span><span>
</span><span id="line-401"></span><span>                                 </span><span class="hs-comment">--</span><span>
</span><span id="line-402"></span><span>                                 </span><span class="hs-comment">-- * A @deriving@ clause (in which case</span><span>
</span><span id="line-403"></span><span>                                 </span><span class="hs-comment">--   @mb_wildcard@ is 'Nothing').</span><span>
</span><span id="line-404"></span><span>                                 </span><span class="hs-comment">--</span><span>
</span><span id="line-405"></span><span>                                 </span><span class="hs-comment">-- * A standalone deriving declaration with</span><span>
</span><span id="line-406"></span><span>                                 </span><span class="hs-comment">--   an extra-constraints wildcard as the</span><span>
</span><span id="line-407"></span><span>                                 </span><span class="hs-comment">--   context (in which case @mb_wildcard@ is</span><span>
</span><span id="line-408"></span><span>                                 </span><span class="hs-comment">--   @'Just' loc@, where @loc@ is the location</span><span>
</span><span id="line-409"></span><span>                                 </span><span class="hs-comment">--   of the wildcard.</span><span>
</span><span id="line-410"></span><span>                                 </span><span class="hs-comment">--</span><span>
</span><span id="line-411"></span><span>                                 </span><span class="hs-comment">-- GHC should infer the context.</span><span>
</span><span id="line-412"></span><span>
</span><span id="line-413"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="SupplyContext"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#SupplyContext"><span class="hs-identifier hs-var">SupplyContext</span></a></span></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ThetaType"><span class="hs-identifier hs-type">ThetaType</span></a></span><span>      </span><span class="hs-comment">-- ^ @'SupplyContext' theta@ is a standalone</span><span>
</span><span id="line-414"></span><span>                                 </span><span class="hs-comment">-- deriving declaration, where @theta@ is the</span><span>
</span><span id="line-415"></span><span>                                 </span><span class="hs-comment">-- context supplied by the user.</span><span>
</span><span id="line-416"></span><span>
</span><span id="line-417"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681170087"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivContext"><span class="hs-identifier hs-type">DerivContext</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-418"></span><span>  </span><span id="local-6989586621681170083"><span class="annot"><span class="annottext">ppr :: DerivContext -&gt; SDoc
</span><a href="#local-6989586621681170083"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#InferContext"><span class="hs-identifier hs-type">InferContext</span></a></span><span> </span><span id="local-6989586621681170082"><span class="annot"><span class="annottext">Maybe SrcSpan
</span><a href="#local-6989586621681170082"><span class="hs-identifier hs-var">standalone</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;InferContext&quot;</span></span><span>  </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe SrcSpan -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe SrcSpan
</span><a href="#local-6989586621681170082"><span class="hs-identifier hs-var">standalone</span></a></span><span>
</span><span id="line-419"></span><span>  </span><span class="annot"><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#SupplyContext"><span class="hs-identifier hs-type">SupplyContext</span></a></span><span> </span><span id="local-6989586621681170081"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681170081"><span class="hs-identifier hs-var">theta</span></a></span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;SupplyContext&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681170081"><span class="hs-identifier hs-var">theta</span></a></span><span>
</span><span id="line-420"></span><span>
</span><span id="line-421"></span><span class="hs-comment">-- | Records whether a particular class can be derived by way of an</span><span>
</span><span id="line-422"></span><span class="hs-comment">-- /originative/ deriving strategy (i.e., @stock@ or @anyclass@).</span><span>
</span><span id="line-423"></span><span class="hs-comment">--</span><span>
</span><span id="line-424"></span><span class="hs-comment">-- See @Note [Deriving strategies]@ in &quot;GHC.Tc.Deriv&quot;.</span><span>
</span><span id="line-425"></span><span class="hs-keyword">data</span><span> </span><span id="OriginativeDerivStatus"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#OriginativeDerivStatus"><span class="hs-identifier hs-var">OriginativeDerivStatus</span></a></span></span><span>
</span><span id="line-426"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="CanDeriveStock"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#CanDeriveStock"><span class="hs-identifier hs-var">CanDeriveStock</span></a></span></span><span>            </span><span class="hs-comment">-- Stock class, can derive</span><span>
</span><span id="line-427"></span><span>      </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#SrcSpan"><span class="hs-identifier hs-type">SrcSpan</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-428"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBinds"><span class="hs-identifier hs-type">LHsBinds</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcPs"><span class="hs-identifier hs-type">GhcPs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Generate.html#BagDerivStuff"><span class="hs-identifier hs-type">BagDerivStuff</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-429"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="StockClassError"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#StockClassError"><span class="hs-identifier hs-var">StockClassError</span></a></span></span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>      </span><span class="hs-comment">-- Stock class, but can't do it</span><span>
</span><span id="line-430"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="CanDeriveAnyClass"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#CanDeriveAnyClass"><span class="hs-identifier hs-var">CanDeriveAnyClass</span></a></span></span><span>         </span><span class="hs-comment">-- See Note [Deriving any class]</span><span>
</span><span id="line-431"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="NonDerivableClass"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#NonDerivableClass"><span class="hs-identifier hs-var">NonDerivableClass</span></a></span></span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>    </span><span class="hs-comment">-- Cannot derive with either stock or anyclass</span><span>
</span><span id="line-432"></span><span>
</span><span id="line-433"></span><span class="hs-comment">-- A stock class is one either defined in the Haskell report or for which GHC</span><span>
</span><span id="line-434"></span><span class="hs-comment">-- otherwise knows how to generate code for (possibly requiring the use of a</span><span>
</span><span id="line-435"></span><span class="hs-comment">-- language extension), such as Eq, Ord, Ix, Data, Generic, etc.)</span><span>
</span><span id="line-436"></span><span>
</span><span id="line-437"></span><span class="hs-comment">-- | A 'PredType' annotated with the origin of the constraint 'CtOrigin',</span><span>
</span><span id="line-438"></span><span class="hs-comment">-- and whether or the constraint deals in types or kinds.</span><span>
</span><span id="line-439"></span><span class="hs-keyword">data</span><span> </span><span id="PredOrigin"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#PredOrigin"><span class="hs-identifier hs-var">PredOrigin</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="PredOrigin"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#PredOrigin"><span class="hs-identifier hs-var">PredOrigin</span></a></span></span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TypeOrKind"><span class="hs-identifier hs-type">TypeOrKind</span></a></span><span>
</span><span id="line-440"></span><span>
</span><span id="line-441"></span><span class="hs-comment">-- | A list of wanted 'PredOrigin' constraints ('to_wanted_origins') to</span><span>
</span><span id="line-442"></span><span class="hs-comment">-- simplify when inferring a derived instance's context. These are used in all</span><span>
</span><span id="line-443"></span><span class="hs-comment">-- deriving strategies, but in the particular case of @DeriveAnyClass@, we</span><span>
</span><span id="line-444"></span><span class="hs-comment">-- need extra information. In particular, we need:</span><span>
</span><span id="line-445"></span><span class="hs-comment">--</span><span>
</span><span id="line-446"></span><span class="hs-comment">-- * 'to_anyclass_skols', the list of type variables bound by a class method's</span><span>
</span><span id="line-447"></span><span class="hs-comment">--   regular type signature, which should be rigid.</span><span>
</span><span id="line-448"></span><span class="hs-comment">--</span><span>
</span><span id="line-449"></span><span class="hs-comment">-- * 'to_anyclass_metas', the list of type variables bound by a class method's</span><span>
</span><span id="line-450"></span><span class="hs-comment">--   default type signature. These can be unified as necessary.</span><span>
</span><span id="line-451"></span><span class="hs-comment">--</span><span>
</span><span id="line-452"></span><span class="hs-comment">-- * 'to_anyclass_givens', the list of constraints from a class method's</span><span>
</span><span id="line-453"></span><span class="hs-comment">--   regular type signature, which can be used to help solve constraints</span><span>
</span><span id="line-454"></span><span class="hs-comment">--   in the 'to_wanted_origins'.</span><span>
</span><span id="line-455"></span><span class="hs-comment">--</span><span>
</span><span id="line-456"></span><span class="hs-comment">-- (Note that 'to_wanted_origins' will likely contain type variables from the</span><span>
</span><span id="line-457"></span><span class="hs-comment">-- derived type class or data type, neither of which will appear in</span><span>
</span><span id="line-458"></span><span class="hs-comment">-- 'to_anyclass_skols' or 'to_anyclass_metas'.)</span><span>
</span><span id="line-459"></span><span class="hs-comment">--</span><span>
</span><span id="line-460"></span><span class="hs-comment">-- For all other deriving strategies, it is always the case that</span><span>
</span><span id="line-461"></span><span class="hs-comment">-- 'to_anyclass_skols', 'to_anyclass_metas', and 'to_anyclass_givens' are</span><span>
</span><span id="line-462"></span><span class="hs-comment">-- empty.</span><span>
</span><span id="line-463"></span><span class="hs-comment">--</span><span>
</span><span id="line-464"></span><span class="hs-comment">-- Here is an example to illustrate this:</span><span>
</span><span id="line-465"></span><span class="hs-comment">--</span><span>
</span><span id="line-466"></span><span class="hs-comment">-- @</span><span>
</span><span id="line-467"></span><span class="hs-comment">-- class Foo a where</span><span>
</span><span id="line-468"></span><span class="hs-comment">--   bar :: forall b. Ix b =&gt; a -&gt; b -&gt; String</span><span>
</span><span id="line-469"></span><span class="hs-comment">--   default bar :: forall y. (Show a, Ix y) =&gt; a -&gt; y -&gt; String</span><span>
</span><span id="line-470"></span><span class="hs-comment">--   bar x y = show x ++ show (range (y, y))</span><span>
</span><span id="line-471"></span><span class="hs-comment">--</span><span>
</span><span id="line-472"></span><span class="hs-comment">--   baz :: Eq a =&gt; a -&gt; a -&gt; Bool</span><span>
</span><span id="line-473"></span><span class="hs-comment">--   default baz :: Ord a =&gt; a -&gt; a -&gt; Bool</span><span>
</span><span id="line-474"></span><span class="hs-comment">--   baz x y = compare x y == EQ</span><span>
</span><span id="line-475"></span><span class="hs-comment">--</span><span>
</span><span id="line-476"></span><span class="hs-comment">-- data Quux q = Quux deriving anyclass Foo</span><span>
</span><span id="line-477"></span><span class="hs-comment">-- @</span><span>
</span><span id="line-478"></span><span class="hs-comment">--</span><span>
</span><span id="line-479"></span><span class="hs-comment">-- Then it would generate two 'ThetaOrigin's, one for each method:</span><span>
</span><span id="line-480"></span><span class="hs-comment">--</span><span>
</span><span id="line-481"></span><span class="hs-comment">-- @</span><span>
</span><span id="line-482"></span><span class="hs-comment">-- [ ThetaOrigin { to_anyclass_skols  = [b]</span><span>
</span><span id="line-483"></span><span class="hs-comment">--               , to_anyclass_metas  = [y]</span><span>
</span><span id="line-484"></span><span class="hs-comment">--               , to_anyclass_givens = [Ix b]</span><span>
</span><span id="line-485"></span><span class="hs-comment">--               , to_wanted_origins  = [ Show (Quux q), Ix y</span><span>
</span><span id="line-486"></span><span class="hs-comment">--                                      , (Quux q -&gt; b -&gt; String) ~</span><span>
</span><span id="line-487"></span><span class="hs-comment">--                                        (Quux q -&gt; y -&gt; String)</span><span>
</span><span id="line-488"></span><span class="hs-comment">--                                      ] }</span><span>
</span><span id="line-489"></span><span class="hs-comment">-- , ThetaOrigin { to_anyclass_skols  = []</span><span>
</span><span id="line-490"></span><span class="hs-comment">--               , to_anyclass_metas  = []</span><span>
</span><span id="line-491"></span><span class="hs-comment">--               , to_anyclass_givens = [Eq (Quux q)]</span><span>
</span><span id="line-492"></span><span class="hs-comment">--               , to_wanted_origins  = [ Ord (Quux q)</span><span>
</span><span id="line-493"></span><span class="hs-comment">--                                      , (Quux q -&gt; Quux q -&gt; Bool) ~</span><span>
</span><span id="line-494"></span><span class="hs-comment">--                                        (Quux q -&gt; Quux q -&gt; Bool)</span><span>
</span><span id="line-495"></span><span class="hs-comment">--                                      ] }</span><span>
</span><span id="line-496"></span><span class="hs-comment">-- ]</span><span>
</span><span id="line-497"></span><span class="hs-comment">-- @</span><span>
</span><span id="line-498"></span><span class="hs-comment">--</span><span>
</span><span id="line-499"></span><span class="hs-comment">-- (Note that the type variable @q@ is bound by the data type @Quux@, and thus</span><span>
</span><span id="line-500"></span><span class="hs-comment">-- it appears in neither 'to_anyclass_skols' nor 'to_anyclass_metas'.)</span><span>
</span><span id="line-501"></span><span class="hs-comment">--</span><span>
</span><span id="line-502"></span><span class="hs-comment">-- See @Note [Gathering and simplifying constraints for DeriveAnyClass]@</span><span>
</span><span id="line-503"></span><span class="hs-comment">-- in &quot;GHC.Tc.Deriv.Infer&quot; for an explanation of how 'to_wanted_origins' are</span><span>
</span><span id="line-504"></span><span class="hs-comment">-- determined in @DeriveAnyClass@, as well as how 'to_anyclass_skols',</span><span>
</span><span id="line-505"></span><span class="hs-comment">-- 'to_anyclass_metas', and 'to_anyclass_givens' are used.</span><span>
</span><span id="line-506"></span><span class="hs-keyword">data</span><span> </span><span id="ThetaOrigin"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#ThetaOrigin"><span class="hs-identifier hs-var">ThetaOrigin</span></a></span></span><span>
</span><span id="line-507"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="ThetaOrigin"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#ThetaOrigin"><span class="hs-identifier hs-var">ThetaOrigin</span></a></span></span><span> </span><span class="hs-special">{</span><span> </span><span id="to_anyclass_skols"><span class="annot"><span class="annottext">ThetaOrigin -&gt; [TyVar]
</span><a href="GHC.Tc.Deriv.Utils.html#to_anyclass_skols"><span class="hs-identifier hs-var hs-var">to_anyclass_skols</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-508"></span><span>                </span><span class="hs-special">,</span><span> </span><span id="to_anyclass_metas"><span class="annot"><span class="annottext">ThetaOrigin -&gt; [TyVar]
</span><a href="GHC.Tc.Deriv.Utils.html#to_anyclass_metas"><span class="hs-identifier hs-var hs-var">to_anyclass_metas</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-509"></span><span>                </span><span class="hs-special">,</span><span> </span><span id="to_anyclass_givens"><span class="annot"><span class="annottext">ThetaOrigin -&gt; [Type]
</span><a href="GHC.Tc.Deriv.Utils.html#to_anyclass_givens"><span class="hs-identifier hs-var hs-var">to_anyclass_givens</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ThetaType"><span class="hs-identifier hs-type">ThetaType</span></a></span><span>
</span><span id="line-510"></span><span>                </span><span class="hs-special">,</span><span> </span><span id="to_wanted_origins"><span class="annot"><span class="annottext">ThetaOrigin -&gt; [PredOrigin]
</span><a href="GHC.Tc.Deriv.Utils.html#to_wanted_origins"><span class="hs-identifier hs-var hs-var">to_wanted_origins</span></a></span></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#PredOrigin"><span class="hs-identifier hs-type">PredOrigin</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-511"></span><span>
</span><span id="line-512"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681170067"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#PredOrigin"><span class="hs-identifier hs-type">PredOrigin</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-513"></span><span>  </span><span id="local-6989586621681170065"><span class="annot"><span class="annottext">ppr :: PredOrigin -&gt; SDoc
</span><a href="#local-6989586621681170065"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#PredOrigin"><span class="hs-identifier hs-type">PredOrigin</span></a></span><span> </span><span id="local-6989586621681170064"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681170064"><span class="hs-identifier hs-var">ty</span></a></span></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681170064"><span class="hs-identifier hs-var">ty</span></a></span><span> </span><span class="hs-comment">-- The origin is not so interesting when debugging</span><span>
</span><span id="line-514"></span><span>
</span><span id="line-515"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621681170061"><span class="annot"><a href="GHC.Utils.Outputable.html#Outputable"><span class="hs-identifier hs-type">Outputable</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#ThetaOrigin"><span class="hs-identifier hs-type">ThetaOrigin</span></a></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-516"></span><span>  </span><span id="local-6989586621681170054"><span class="annot"><span class="annottext">ppr :: ThetaOrigin -&gt; SDoc
</span><a href="#local-6989586621681170054"><span class="hs-identifier hs-var hs-var hs-var hs-var">ppr</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#ThetaOrigin"><span class="hs-identifier hs-type">ThetaOrigin</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">to_anyclass_skols :: ThetaOrigin -&gt; [TyVar]
</span><a href="GHC.Tc.Deriv.Utils.html#to_anyclass_skols"><span class="hs-identifier hs-var">to_anyclass_skols</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170053"><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681170053"><span class="hs-identifier hs-var">ac_skols</span></a></span></span><span>
</span><span id="line-517"></span><span>                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">to_anyclass_metas :: ThetaOrigin -&gt; [TyVar]
</span><a href="GHC.Tc.Deriv.Utils.html#to_anyclass_metas"><span class="hs-identifier hs-var">to_anyclass_metas</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170052"><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681170052"><span class="hs-identifier hs-var">ac_metas</span></a></span></span><span>
</span><span id="line-518"></span><span>                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">to_anyclass_givens :: ThetaOrigin -&gt; [Type]
</span><a href="GHC.Tc.Deriv.Utils.html#to_anyclass_givens"><span class="hs-identifier hs-var">to_anyclass_givens</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170051"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681170051"><span class="hs-identifier hs-var">ac_givens</span></a></span></span><span>
</span><span id="line-519"></span><span>                   </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">to_wanted_origins :: ThetaOrigin -&gt; [PredOrigin]
</span><a href="GHC.Tc.Deriv.Utils.html#to_wanted_origins"><span class="hs-identifier hs-var">to_wanted_origins</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681170050"><span class="annot"><span class="annottext">[PredOrigin]
</span><a href="#local-6989586621681170050"><span class="hs-identifier hs-var">wanted_origins</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-520"></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;ThetaOrigin&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-521"></span><span>         </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;to_anyclass_skols  =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681170053"><span class="hs-identifier hs-var">ac_skols</span></a></span><span>
</span><span id="line-522"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;to_anyclass_metas  =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681170052"><span class="hs-identifier hs-var">ac_metas</span></a></span><span>
</span><span id="line-523"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;to_anyclass_givens =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681170051"><span class="hs-identifier hs-var">ac_givens</span></a></span><span>
</span><span id="line-524"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;to_wanted_origins  =&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[PredOrigin] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[PredOrigin]
</span><a href="#local-6989586621681170050"><span class="hs-identifier hs-var">wanted_origins</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-525"></span><span>
</span><span id="line-526"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#mkPredOrigin"><span class="hs-identifier hs-type">mkPredOrigin</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TypeOrKind"><span class="hs-identifier hs-type">TypeOrKind</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#PredType"><span class="hs-identifier hs-type">PredType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#PredOrigin"><span class="hs-identifier hs-type">PredOrigin</span></a></span><span>
</span><span id="line-527"></span><span id="mkPredOrigin"><span class="annot"><span class="annottext">mkPredOrigin :: CtOrigin -&gt; TypeOrKind -&gt; Type -&gt; PredOrigin
</span><a href="GHC.Tc.Deriv.Utils.html#mkPredOrigin"><span class="hs-identifier hs-var hs-var">mkPredOrigin</span></a></span></span><span> </span><span id="local-6989586621681170049"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681170049"><span class="hs-identifier hs-var">origin</span></a></span></span><span> </span><span id="local-6989586621681170048"><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681170048"><span class="hs-identifier hs-var">t_or_k</span></a></span></span><span> </span><span id="local-6989586621681170047"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681170047"><span class="hs-identifier hs-var">pred</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; CtOrigin -&gt; TypeOrKind -&gt; PredOrigin
</span><a href="GHC.Tc.Deriv.Utils.html#PredOrigin"><span class="hs-identifier hs-var">PredOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681170047"><span class="hs-identifier hs-var">pred</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681170049"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681170048"><span class="hs-identifier hs-var">t_or_k</span></a></span><span>
</span><span id="line-528"></span><span>
</span><span id="line-529"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#mkThetaOrigin"><span class="hs-identifier hs-type">mkThetaOrigin</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Types.Origin.html#CtOrigin"><span class="hs-identifier hs-type">CtOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#TypeOrKind"><span class="hs-identifier hs-type">TypeOrKind</span></a></span><span>
</span><span id="line-530"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Var.html#TyVar"><span class="hs-identifier hs-type">TyVar</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ThetaType"><span class="hs-identifier hs-type">ThetaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ThetaType"><span class="hs-identifier hs-type">ThetaType</span></a></span><span>
</span><span id="line-531"></span><span>              </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#ThetaOrigin"><span class="hs-identifier hs-type">ThetaOrigin</span></a></span><span>
</span><span id="line-532"></span><span id="mkThetaOrigin"><span class="annot"><span class="annottext">mkThetaOrigin :: CtOrigin
-&gt; TypeOrKind
-&gt; [TyVar]
-&gt; [TyVar]
-&gt; [Type]
-&gt; [Type]
-&gt; ThetaOrigin
</span><a href="GHC.Tc.Deriv.Utils.html#mkThetaOrigin"><span class="hs-identifier hs-var hs-var">mkThetaOrigin</span></a></span></span><span> </span><span id="local-6989586621681170046"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681170046"><span class="hs-identifier hs-var">origin</span></a></span></span><span> </span><span id="local-6989586621681170045"><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681170045"><span class="hs-identifier hs-var">t_or_k</span></a></span></span><span> </span><span id="local-6989586621681170044"><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681170044"><span class="hs-identifier hs-var">skols</span></a></span></span><span> </span><span id="local-6989586621681170043"><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681170043"><span class="hs-identifier hs-var">metas</span></a></span></span><span> </span><span id="local-6989586621681170042"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681170042"><span class="hs-identifier hs-var">givens</span></a></span></span><span>
</span><span id="line-533"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; [TyVar] -&gt; [Type] -&gt; [PredOrigin] -&gt; ThetaOrigin
</span><a href="GHC.Tc.Deriv.Utils.html#ThetaOrigin"><span class="hs-identifier hs-var">ThetaOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681170044"><span class="hs-identifier hs-var">skols</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681170043"><span class="hs-identifier hs-var">metas</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681170042"><span class="hs-identifier hs-var">givens</span></a></span><span> </span><span class="annot"><span class="annottext">([PredOrigin] -&gt; ThetaOrigin)
-&gt; ([Type] -&gt; [PredOrigin]) -&gt; [Type] -&gt; ThetaOrigin
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; PredOrigin) -&gt; [Type] -&gt; [PredOrigin]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">CtOrigin -&gt; TypeOrKind -&gt; Type -&gt; PredOrigin
</span><a href="GHC.Tc.Deriv.Utils.html#mkPredOrigin"><span class="hs-identifier hs-var">mkPredOrigin</span></a></span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681170046"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681170045"><span class="hs-identifier hs-var">t_or_k</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-534"></span><span>
</span><span id="line-535"></span><span class="hs-comment">-- A common case where the ThetaOrigin only contains wanted constraints, with</span><span>
</span><span id="line-536"></span><span class="hs-comment">-- no givens or locally scoped type variables.</span><span>
</span><span id="line-537"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#mkThetaOriginFromPreds"><span class="hs-identifier hs-type">mkThetaOriginFromPreds</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#PredOrigin"><span class="hs-identifier hs-type">PredOrigin</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#ThetaOrigin"><span class="hs-identifier hs-type">ThetaOrigin</span></a></span><span>
</span><span id="line-538"></span><span id="mkThetaOriginFromPreds"><span class="annot"><span class="annottext">mkThetaOriginFromPreds :: [PredOrigin] -&gt; ThetaOrigin
</span><a href="GHC.Tc.Deriv.Utils.html#mkThetaOriginFromPreds"><span class="hs-identifier hs-var hs-var">mkThetaOriginFromPreds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; [TyVar] -&gt; [Type] -&gt; [PredOrigin] -&gt; ThetaOrigin
</span><a href="GHC.Tc.Deriv.Utils.html#ThetaOrigin"><span class="hs-identifier hs-var">ThetaOrigin</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-539"></span><span>
</span><span id="line-540"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#substPredOrigin"><span class="hs-identifier hs-type">substPredOrigin</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../base/src/GHC.Stack.Types.html#HasCallStack"><span class="hs-identifier hs-type">HasCallStack</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Subst.html#TCvSubst"><span class="hs-identifier hs-type">TCvSubst</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#PredOrigin"><span class="hs-identifier hs-type">PredOrigin</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#PredOrigin"><span class="hs-identifier hs-type">PredOrigin</span></a></span><span>
</span><span id="line-541"></span><span id="substPredOrigin"><span class="annot"><span class="annottext">substPredOrigin :: HasCallStack =&gt; TCvSubst -&gt; PredOrigin -&gt; PredOrigin
</span><a href="GHC.Tc.Deriv.Utils.html#substPredOrigin"><span class="hs-identifier hs-var hs-var">substPredOrigin</span></a></span></span><span> </span><span id="local-6989586621681170038"><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681170038"><span class="hs-identifier hs-var">subst</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#PredOrigin"><span class="hs-identifier hs-type">PredOrigin</span></a></span><span> </span><span id="local-6989586621681170037"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681170037"><span class="hs-identifier hs-var">pred</span></a></span></span><span> </span><span id="local-6989586621681170036"><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681170036"><span class="hs-identifier hs-var">origin</span></a></span></span><span> </span><span id="local-6989586621681170035"><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681170035"><span class="hs-identifier hs-var">t_or_k</span></a></span></span><span class="hs-special">)</span><span>
</span><span id="line-542"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; CtOrigin -&gt; TypeOrKind -&gt; PredOrigin
</span><a href="GHC.Tc.Deriv.Utils.html#PredOrigin"><span class="hs-identifier hs-var">PredOrigin</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">HasCallStack =&gt; TCvSubst -&gt; Type -&gt; Type
TCvSubst -&gt; Type -&gt; Type
</span><a href="GHC.Core.TyCo.Subst.html#substTy"><span class="hs-identifier hs-var">substTy</span></a></span><span> </span><span class="annot"><span class="annottext">TCvSubst
</span><a href="#local-6989586621681170038"><span class="hs-identifier hs-var">subst</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681170037"><span class="hs-identifier hs-var">pred</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">CtOrigin
</span><a href="#local-6989586621681170036"><span class="hs-identifier hs-var">origin</span></a></span><span> </span><span class="annot"><span class="annottext">TypeOrKind
</span><a href="#local-6989586621681170035"><span class="hs-identifier hs-var">t_or_k</span></a></span><span>
</span><span id="line-543"></span><span>
</span><span id="line-544"></span><span class="hs-comment">{-
************************************************************************
*                                                                      *
                Class deriving diagnostics
*                                                                      *
************************************************************************

Only certain blessed classes can be used in a deriving clause (without the
assistance of GeneralizedNewtypeDeriving or DeriveAnyClass). These classes
are listed below in the definition of hasStockDeriving. The stockSideConditions
function determines the criteria that needs to be met in order for a particular
stock class to be able to be derived successfully.

A class might be able to be used in a deriving clause if -XDeriveAnyClass
is willing to support it. The canDeriveAnyClass function checks if this is the
case.
-}</span><span>
</span><span id="line-561"></span><span>
</span><span id="line-562"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#hasStockDeriving"><span class="hs-identifier hs-type">hasStockDeriving</span></a></span><span>
</span><span id="line-563"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.SrcLoc.html#SrcSpan"><span class="hs-identifier hs-type">SrcSpan</span></a></span><span>
</span><span id="line-564"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span>
</span><span id="line-565"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-566"></span><span>                     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBinds"><span class="hs-identifier hs-type">LHsBinds</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcPs"><span class="hs-identifier hs-type">GhcPs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Generate.html#BagDerivStuff"><span class="hs-identifier hs-type">BagDerivStuff</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-567"></span><span id="hasStockDeriving"><span class="annot"><span class="annottext">hasStockDeriving :: Class
-&gt; Maybe
     (SrcSpan
      -&gt; TyCon -&gt; [Type] -&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name]))
</span><a href="GHC.Tc.Deriv.Utils.html#hasStockDeriving"><span class="hs-identifier hs-var hs-var">hasStockDeriving</span></a></span></span><span> </span><span id="local-6989586621681170033"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681170033"><span class="hs-identifier hs-var">clas</span></a></span></span><span>
</span><span id="line-568"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Assoc
  Unique
  (SrcSpan
   -&gt; TyCon -&gt; [Type] -&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name]))
-&gt; Unique
-&gt; Maybe
     (SrcSpan
      -&gt; TyCon -&gt; [Type] -&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name]))
forall a b. Eq a =&gt; Assoc a b -&gt; a -&gt; Maybe b
</span><a href="GHC.Data.List.SetOps.html#assocMaybe"><span class="hs-identifier hs-var">assocMaybe</span></a></span><span> </span><span class="annot"><span class="annottext">Assoc
  Unique
  (SrcSpan
   -&gt; TyCon -&gt; [Type] -&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name]))
</span><a href="#local-6989586621681170032"><span class="hs-identifier hs-var">gen_list</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; Unique
forall a. Uniquable a =&gt; a -&gt; Unique
</span><a href="GHC.Types.Unique.html#getUnique"><span class="hs-identifier hs-var">getUnique</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681170033"><span class="hs-identifier hs-var">clas</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-569"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-570"></span><span>    </span><span class="annot"><a href="#local-6989586621681170032"><span class="hs-identifier hs-type">gen_list</span></a></span><span>
</span><span id="line-571"></span><span>      </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Unique.html#Unique"><span class="hs-identifier hs-type">Unique</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Types.SrcLoc.html#SrcSpan"><span class="hs-identifier hs-type">SrcSpan</span></a></span><span>
</span><span id="line-572"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span>
</span><span id="line-573"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-574"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Hs.Binds.html#LHsBinds"><span class="hs-identifier hs-type">LHsBinds</span></a></span><span> </span><span class="annot"><a href="GHC.Hs.Extension.html#GhcPs"><span class="hs-identifier hs-type">GhcPs</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Generate.html#BagDerivStuff"><span class="hs-identifier hs-type">BagDerivStuff</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-575"></span><span>    </span><span id="local-6989586621681170032"><span class="annot"><span class="annottext">gen_list :: Assoc
  Unique
  (SrcSpan
   -&gt; TyCon -&gt; [Type] -&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name]))
</span><a href="#local-6989586621681170032"><span class="hs-identifier hs-var hs-var">gen_list</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#eqClassKey"><span class="hs-identifier hs-var">eqClassKey</span></a></span><span class="hs-special">,</span><span>          </span><span class="annot"><span class="annottext">(SrcSpan
 -&gt; TyCon
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) (LHsBinds GhcPs, BagDerivStuff))
-&gt; SrcSpan
-&gt; TyCon
-&gt; [Type]
-&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name])
forall {m :: * -&gt; *} {t} {t} {a} {b} {p} {a}.
Monad m =&gt;
(t -&gt; t -&gt; m (a, b)) -&gt; t -&gt; t -&gt; p -&gt; m (a, b, [a])
</span><a href="#local-6989586621681170029"><span class="hs-identifier hs-var">simpleM</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
-&gt; TyCon
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (LHsBinds GhcPs, BagDerivStuff)
</span><a href="GHC.Tc.Deriv.Generate.html#gen_Eq_binds"><span class="hs-identifier hs-var">gen_Eq_binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-576"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#ordClassKey"><span class="hs-identifier hs-var">ordClassKey</span></a></span><span class="hs-special">,</span><span>         </span><span class="annot"><span class="annottext">(SrcSpan
 -&gt; TyCon
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) (LHsBinds GhcPs, BagDerivStuff))
-&gt; SrcSpan
-&gt; TyCon
-&gt; [Type]
-&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name])
forall {m :: * -&gt; *} {t} {t} {a} {b} {p} {a}.
Monad m =&gt;
(t -&gt; t -&gt; m (a, b)) -&gt; t -&gt; t -&gt; p -&gt; m (a, b, [a])
</span><a href="#local-6989586621681170029"><span class="hs-identifier hs-var">simpleM</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
-&gt; TyCon
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (LHsBinds GhcPs, BagDerivStuff)
</span><a href="GHC.Tc.Deriv.Generate.html#gen_Ord_binds"><span class="hs-identifier hs-var">gen_Ord_binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-577"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#enumClassKey"><span class="hs-identifier hs-var">enumClassKey</span></a></span><span class="hs-special">,</span><span>        </span><span class="annot"><span class="annottext">(SrcSpan
 -&gt; TyCon
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) (LHsBinds GhcPs, BagDerivStuff))
-&gt; SrcSpan
-&gt; TyCon
-&gt; [Type]
-&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name])
forall {m :: * -&gt; *} {t} {t} {a} {b} {p} {a}.
Monad m =&gt;
(t -&gt; t -&gt; m (a, b)) -&gt; t -&gt; t -&gt; p -&gt; m (a, b, [a])
</span><a href="#local-6989586621681170029"><span class="hs-identifier hs-var">simpleM</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
-&gt; TyCon
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (LHsBinds GhcPs, BagDerivStuff)
</span><a href="GHC.Tc.Deriv.Generate.html#gen_Enum_binds"><span class="hs-identifier hs-var">gen_Enum_binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-578"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#boundedClassKey"><span class="hs-identifier hs-var">boundedClassKey</span></a></span><span class="hs-special">,</span><span>     </span><span class="annot"><span class="annottext">(SrcSpan -&gt; TyCon -&gt; (LHsBinds GhcPs, BagDerivStuff))
-&gt; SrcSpan
-&gt; TyCon
-&gt; [Type]
-&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name])
forall {m :: * -&gt; *} {t} {t} {a} {b} {p} {a}.
Monad m =&gt;
(t -&gt; t -&gt; (a, b)) -&gt; t -&gt; t -&gt; p -&gt; m (a, b, [a])
</span><a href="#local-6989586621681170022"><span class="hs-identifier hs-var">simple</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; TyCon -&gt; (LHsBinds GhcPs, BagDerivStuff)
</span><a href="GHC.Tc.Deriv.Generate.html#gen_Bounded_binds"><span class="hs-identifier hs-var">gen_Bounded_binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-579"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#ixClassKey"><span class="hs-identifier hs-var">ixClassKey</span></a></span><span class="hs-special">,</span><span>          </span><span class="annot"><span class="annottext">(SrcSpan
 -&gt; TyCon
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) (LHsBinds GhcPs, BagDerivStuff))
-&gt; SrcSpan
-&gt; TyCon
-&gt; [Type]
-&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name])
forall {m :: * -&gt; *} {t} {t} {a} {b} {p} {a}.
Monad m =&gt;
(t -&gt; t -&gt; m (a, b)) -&gt; t -&gt; t -&gt; p -&gt; m (a, b, [a])
</span><a href="#local-6989586621681170029"><span class="hs-identifier hs-var">simpleM</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
-&gt; TyCon
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (LHsBinds GhcPs, BagDerivStuff)
</span><a href="GHC.Tc.Deriv.Generate.html#gen_Ix_binds"><span class="hs-identifier hs-var">gen_Ix_binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-580"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#showClassKey"><span class="hs-identifier hs-var">showClassKey</span></a></span><span class="hs-special">,</span><span>        </span><span class="annot"><span class="annottext">((Name -&gt; Fixity)
 -&gt; SrcSpan -&gt; TyCon -&gt; (LHsBinds GhcPs, BagDerivStuff))
-&gt; SrcSpan
-&gt; TyCon
-&gt; [Type]
-&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name])
forall {t} {a} {b} {p}.
((Name -&gt; Fixity) -&gt; t -&gt; TyCon -&gt; (a, b))
-&gt; t -&gt; TyCon -&gt; p -&gt; IOEnv (Env TcGblEnv TcLclEnv) (a, b, [Name])
</span><a href="#local-6989586621681170017"><span class="hs-identifier hs-var">read_or_show</span></a></span><span> </span><span class="annot"><span class="annottext">(Name -&gt; Fixity)
-&gt; SrcSpan -&gt; TyCon -&gt; (LHsBinds GhcPs, BagDerivStuff)
</span><a href="GHC.Tc.Deriv.Generate.html#gen_Show_binds"><span class="hs-identifier hs-var">gen_Show_binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-581"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#readClassKey"><span class="hs-identifier hs-var">readClassKey</span></a></span><span class="hs-special">,</span><span>        </span><span class="annot"><span class="annottext">((Name -&gt; Fixity)
 -&gt; SrcSpan -&gt; TyCon -&gt; (LHsBinds GhcPs, BagDerivStuff))
-&gt; SrcSpan
-&gt; TyCon
-&gt; [Type]
-&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name])
forall {t} {a} {b} {p}.
((Name -&gt; Fixity) -&gt; t -&gt; TyCon -&gt; (a, b))
-&gt; t -&gt; TyCon -&gt; p -&gt; IOEnv (Env TcGblEnv TcLclEnv) (a, b, [Name])
</span><a href="#local-6989586621681170017"><span class="hs-identifier hs-var">read_or_show</span></a></span><span> </span><span class="annot"><span class="annottext">(Name -&gt; Fixity)
-&gt; SrcSpan -&gt; TyCon -&gt; (LHsBinds GhcPs, BagDerivStuff)
</span><a href="GHC.Tc.Deriv.Generate.html#gen_Read_binds"><span class="hs-identifier hs-var">gen_Read_binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-582"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#dataClassKey"><span class="hs-identifier hs-var">dataClassKey</span></a></span><span class="hs-special">,</span><span>        </span><span class="annot"><span class="annottext">(SrcSpan
 -&gt; TyCon
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) (LHsBinds GhcPs, BagDerivStuff))
-&gt; SrcSpan
-&gt; TyCon
-&gt; [Type]
-&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name])
forall {m :: * -&gt; *} {t} {t} {a} {b} {p} {a}.
Monad m =&gt;
(t -&gt; t -&gt; m (a, b)) -&gt; t -&gt; t -&gt; p -&gt; m (a, b, [a])
</span><a href="#local-6989586621681170029"><span class="hs-identifier hs-var">simpleM</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
-&gt; TyCon
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (LHsBinds GhcPs, BagDerivStuff)
</span><a href="GHC.Tc.Deriv.Generate.html#gen_Data_binds"><span class="hs-identifier hs-var">gen_Data_binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-583"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#functorClassKey"><span class="hs-identifier hs-var">functorClassKey</span></a></span><span class="hs-special">,</span><span>     </span><span class="annot"><span class="annottext">(SrcSpan -&gt; TyCon -&gt; (LHsBinds GhcPs, BagDerivStuff))
-&gt; SrcSpan
-&gt; TyCon
-&gt; [Type]
-&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name])
forall {m :: * -&gt; *} {t} {t} {a} {b} {p} {a}.
Monad m =&gt;
(t -&gt; t -&gt; (a, b)) -&gt; t -&gt; t -&gt; p -&gt; m (a, b, [a])
</span><a href="#local-6989586621681170022"><span class="hs-identifier hs-var">simple</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; TyCon -&gt; (LHsBinds GhcPs, BagDerivStuff)
</span><a href="GHC.Tc.Deriv.Functor.html#gen_Functor_binds"><span class="hs-identifier hs-var">gen_Functor_binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-584"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#foldableClassKey"><span class="hs-identifier hs-var">foldableClassKey</span></a></span><span class="hs-special">,</span><span>    </span><span class="annot"><span class="annottext">(SrcSpan -&gt; TyCon -&gt; (LHsBinds GhcPs, BagDerivStuff))
-&gt; SrcSpan
-&gt; TyCon
-&gt; [Type]
-&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name])
forall {m :: * -&gt; *} {t} {t} {a} {b} {p} {a}.
Monad m =&gt;
(t -&gt; t -&gt; (a, b)) -&gt; t -&gt; t -&gt; p -&gt; m (a, b, [a])
</span><a href="#local-6989586621681170022"><span class="hs-identifier hs-var">simple</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; TyCon -&gt; (LHsBinds GhcPs, BagDerivStuff)
</span><a href="GHC.Tc.Deriv.Functor.html#gen_Foldable_binds"><span class="hs-identifier hs-var">gen_Foldable_binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-585"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#traversableClassKey"><span class="hs-identifier hs-var">traversableClassKey</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">(SrcSpan -&gt; TyCon -&gt; (LHsBinds GhcPs, BagDerivStuff))
-&gt; SrcSpan
-&gt; TyCon
-&gt; [Type]
-&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name])
forall {m :: * -&gt; *} {t} {t} {a} {b} {p} {a}.
Monad m =&gt;
(t -&gt; t -&gt; (a, b)) -&gt; t -&gt; t -&gt; p -&gt; m (a, b, [a])
</span><a href="#local-6989586621681170022"><span class="hs-identifier hs-var">simple</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; TyCon -&gt; (LHsBinds GhcPs, BagDerivStuff)
</span><a href="GHC.Tc.Deriv.Functor.html#gen_Traversable_binds"><span class="hs-identifier hs-var">gen_Traversable_binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-586"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.TH.html#liftClassKey"><span class="hs-identifier hs-var">liftClassKey</span></a></span><span class="hs-special">,</span><span>        </span><span class="annot"><span class="annottext">(SrcSpan -&gt; TyCon -&gt; (LHsBinds GhcPs, BagDerivStuff))
-&gt; SrcSpan
-&gt; TyCon
-&gt; [Type]
-&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name])
forall {m :: * -&gt; *} {t} {t} {a} {b} {p} {a}.
Monad m =&gt;
(t -&gt; t -&gt; (a, b)) -&gt; t -&gt; t -&gt; p -&gt; m (a, b, [a])
</span><a href="#local-6989586621681170022"><span class="hs-identifier hs-var">simple</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan -&gt; TyCon -&gt; (LHsBinds GhcPs, BagDerivStuff)
</span><a href="GHC.Tc.Deriv.Generate.html#gen_Lift_binds"><span class="hs-identifier hs-var">gen_Lift_binds</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-587"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#genClassKey"><span class="hs-identifier hs-var">genClassKey</span></a></span><span class="hs-special">,</span><span>         </span><span class="annot"><span class="annottext">(TyCon
 -&gt; [Type]
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) (LHsBinds GhcPs, FamInst))
-&gt; SrcSpan
-&gt; TyCon
-&gt; [Type]
-&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name])
forall {m :: * -&gt; *} {t} {a} {p}.
Monad m =&gt;
(TyCon -&gt; t -&gt; m (a, FamInst))
-&gt; p -&gt; TyCon -&gt; t -&gt; m (a, BagDerivStuff, [Name])
</span><a href="#local-6989586621681170003"><span class="hs-identifier hs-var">generic</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GenericKind
-&gt; TyCon
-&gt; [Type]
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (LHsBinds GhcPs, FamInst)
</span><a href="GHC.Tc.Deriv.Generics.html#gen_Generic_binds"><span class="hs-identifier hs-var">gen_Generic_binds</span></a></span><span> </span><span class="annot"><span class="annottext">GenericKind
</span><a href="GHC.Tc.Deriv.Generics.html#Gen0"><span class="hs-identifier hs-var">Gen0</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-588"></span><span>               </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#gen1ClassKey"><span class="hs-identifier hs-var">gen1ClassKey</span></a></span><span class="hs-special">,</span><span>        </span><span class="annot"><span class="annottext">(TyCon
 -&gt; [Type]
 -&gt; IOEnv (Env TcGblEnv TcLclEnv) (LHsBinds GhcPs, FamInst))
-&gt; SrcSpan
-&gt; TyCon
-&gt; [Type]
-&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name])
forall {m :: * -&gt; *} {t} {a} {p}.
Monad m =&gt;
(TyCon -&gt; t -&gt; m (a, FamInst))
-&gt; p -&gt; TyCon -&gt; t -&gt; m (a, BagDerivStuff, [Name])
</span><a href="#local-6989586621681170003"><span class="hs-identifier hs-var">generic</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">GenericKind
-&gt; TyCon
-&gt; [Type]
-&gt; IOEnv (Env TcGblEnv TcLclEnv) (LHsBinds GhcPs, FamInst)
</span><a href="GHC.Tc.Deriv.Generics.html#gen_Generic_binds"><span class="hs-identifier hs-var">gen_Generic_binds</span></a></span><span> </span><span class="annot"><span class="annottext">GenericKind
</span><a href="GHC.Tc.Deriv.Generics.html#Gen1"><span class="hs-identifier hs-var">Gen1</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-589"></span><span>
</span><span id="line-590"></span><span>    </span><span id="local-6989586621681170022"><span class="annot"><span class="annottext">simple :: (t -&gt; t -&gt; (a, b)) -&gt; t -&gt; t -&gt; p -&gt; m (a, b, [a])
</span><a href="#local-6989586621681170022"><span class="hs-identifier hs-var hs-var">simple</span></a></span></span><span> </span><span id="local-6989586621681169996"><span class="annot"><span class="annottext">t -&gt; t -&gt; (a, b)
</span><a href="#local-6989586621681169996"><span class="hs-identifier hs-var">gen_fn</span></a></span></span><span> </span><span id="local-6989586621681169995"><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621681169995"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span id="local-6989586621681169994"><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621681169994"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span class="annot"><span class="annottext">p
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-591"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681169993"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681169993"><span class="hs-identifier hs-var">binds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681169992"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621681169992"><span class="hs-identifier hs-var">deriv_stuff</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">t -&gt; t -&gt; (a, b)
</span><a href="#local-6989586621681169996"><span class="hs-identifier hs-var">gen_fn</span></a></span><span> </span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621681169995"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621681169994"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-592"></span><span>        </span><span class="hs-keyword">in</span><span> </span><span class="annot"><span class="annottext">(a, b, [a]) -&gt; m (a, b, [a])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681169993"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621681169992"><span class="hs-identifier hs-var">deriv_stuff</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-593"></span><span>
</span><span id="line-594"></span><span>    </span><span class="hs-comment">-- Like `simple`, but monadic. The only monadic thing that these functions</span><span>
</span><span id="line-595"></span><span>    </span><span class="hs-comment">-- do is allocate new Uniques, which are used for generating the names of</span><span>
</span><span id="line-596"></span><span>    </span><span class="hs-comment">-- auxiliary bindings.</span><span>
</span><span id="line-597"></span><span>    </span><span class="hs-comment">-- See Note [Auxiliary binders] in GHC.Tc.Deriv.Generate.</span><span>
</span><span id="line-598"></span><span>    </span><span id="local-6989586621681170029"><span class="annot"><span class="annottext">simpleM :: (t -&gt; t -&gt; m (a, b)) -&gt; t -&gt; t -&gt; p -&gt; m (a, b, [a])
</span><a href="#local-6989586621681170029"><span class="hs-identifier hs-var hs-var">simpleM</span></a></span></span><span> </span><span id="local-6989586621681169988"><span class="annot"><span class="annottext">t -&gt; t -&gt; m (a, b)
</span><a href="#local-6989586621681169988"><span class="hs-identifier hs-var">gen_fn</span></a></span></span><span> </span><span id="local-6989586621681169987"><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621681169987"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span id="local-6989586621681169986"><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621681169986"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span class="annot"><span class="annottext">p
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-599"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681169985"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681169985"><span class="hs-identifier hs-var">binds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681169984"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621681169984"><span class="hs-identifier hs-var">deriv_stuff</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">t -&gt; t -&gt; m (a, b)
</span><a href="#local-6989586621681169988"><span class="hs-identifier hs-var">gen_fn</span></a></span><span> </span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621681169987"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621681169986"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-600"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(a, b, [a]) -&gt; m (a, b, [a])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681169985"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621681169984"><span class="hs-identifier hs-var">deriv_stuff</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-601"></span><span>
</span><span id="line-602"></span><span>    </span><span id="local-6989586621681170017"><span class="annot"><span class="annottext">read_or_show :: ((Name -&gt; Fixity) -&gt; t -&gt; TyCon -&gt; (a, b))
-&gt; t -&gt; TyCon -&gt; p -&gt; IOEnv (Env TcGblEnv TcLclEnv) (a, b, [Name])
</span><a href="#local-6989586621681170017"><span class="hs-identifier hs-var hs-var">read_or_show</span></a></span></span><span> </span><span id="local-6989586621681169981"><span class="annot"><span class="annottext">(Name -&gt; Fixity) -&gt; t -&gt; TyCon -&gt; (a, b)
</span><a href="#local-6989586621681169981"><span class="hs-identifier hs-var">gen_fn</span></a></span></span><span> </span><span id="local-6989586621681169980"><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621681169980"><span class="hs-identifier hs-var">loc</span></a></span></span><span> </span><span id="local-6989586621681169979"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169979"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span class="annot"><span class="annottext">p
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-603"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681169978"><span class="annot"><span class="annottext">Name -&gt; Fixity
</span><a href="#local-6989586621681169978"><span class="hs-identifier hs-var">fix_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; TcM (Name -&gt; Fixity)
</span><a href="GHC.Tc.Deriv.Utils.html#getDataConFixityFun"><span class="hs-identifier hs-var">getDataConFixityFun</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169979"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-604"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681169976"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681169976"><span class="hs-identifier hs-var">binds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681169975"><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621681169975"><span class="hs-identifier hs-var">deriv_stuff</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; Fixity) -&gt; t -&gt; TyCon -&gt; (a, b)
</span><a href="#local-6989586621681169981"><span class="hs-identifier hs-var">gen_fn</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; Fixity
</span><a href="#local-6989586621681169978"><span class="hs-identifier hs-var">fix_env</span></a></span><span> </span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621681169980"><span class="hs-identifier hs-var">loc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169979"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-605"></span><span>                 </span><span id="local-6989586621681169974"><span class="annot"><span class="annottext">field_names :: [Name]
</span><a href="#local-6989586621681169974"><span class="hs-identifier hs-var hs-var">field_names</span></a></span></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [Name]
</span><a href="#local-6989586621681169973"><span class="hs-identifier hs-var">all_field_names</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169979"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-606"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(a, b, [Name]) -&gt; IOEnv (Env TcGblEnv TcLclEnv) (a, b, [Name])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681169976"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">b
</span><a href="#local-6989586621681169975"><span class="hs-identifier hs-var">deriv_stuff</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681169974"><span class="hs-identifier hs-var">field_names</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-607"></span><span>
</span><span id="line-608"></span><span>    </span><span id="local-6989586621681170003"><span class="annot"><span class="annottext">generic :: (TyCon -&gt; t -&gt; m (a, FamInst))
-&gt; p -&gt; TyCon -&gt; t -&gt; m (a, BagDerivStuff, [Name])
</span><a href="#local-6989586621681170003"><span class="hs-identifier hs-var hs-var">generic</span></a></span></span><span> </span><span id="local-6989586621681169969"><span class="annot"><span class="annottext">TyCon -&gt; t -&gt; m (a, FamInst)
</span><a href="#local-6989586621681169969"><span class="hs-identifier hs-var">gen_fn</span></a></span></span><span> </span><span class="annot"><span class="annottext">p
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681169968"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169968"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span id="local-6989586621681169967"><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621681169967"><span class="hs-identifier hs-var">inst_tys</span></a></span></span><span>
</span><span id="line-609"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span class="hs-special">(</span><span id="local-6989586621681169966"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681169966"><span class="hs-identifier hs-var">binds</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681169965"><span class="annot"><span class="annottext">FamInst
</span><a href="#local-6989586621681169965"><span class="hs-identifier hs-var">faminst</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; t -&gt; m (a, FamInst)
</span><a href="#local-6989586621681169969"><span class="hs-identifier hs-var">gen_fn</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169968"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">t
</span><a href="#local-6989586621681169967"><span class="hs-identifier hs-var">inst_tys</span></a></span><span>
</span><span id="line-610"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621681169964"><span class="annot"><span class="annottext">field_names :: [Name]
</span><a href="#local-6989586621681169964"><span class="hs-identifier hs-var hs-var">field_names</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [Name]
</span><a href="#local-6989586621681169973"><span class="hs-identifier hs-var">all_field_names</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169968"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-611"></span><span>           </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(a, BagDerivStuff, [Name]) -&gt; m (a, BagDerivStuff, [Name])
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621681169966"><span class="hs-identifier hs-var">binds</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">DerivStuff -&gt; BagDerivStuff
forall a. a -&gt; Bag a
</span><a href="GHC.Data.Bag.html#unitBag"><span class="hs-identifier hs-var">unitBag</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FamInst -&gt; DerivStuff
</span><a href="GHC.Tc.Deriv.Generate.html#DerivFamInst"><span class="hs-identifier hs-var">DerivFamInst</span></a></span><span> </span><span class="annot"><span class="annottext">FamInst
</span><a href="#local-6989586621681169965"><span class="hs-identifier hs-var">faminst</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Name]
</span><a href="#local-6989586621681169964"><span class="hs-identifier hs-var">field_names</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-612"></span><span>
</span><span id="line-613"></span><span>    </span><span class="hs-comment">-- See Note [Deriving and unused record selectors]</span><span>
</span><span id="line-614"></span><span>    </span><span id="local-6989586621681169973"><span class="annot"><span class="annottext">all_field_names :: TyCon -&gt; [Name]
</span><a href="#local-6989586621681169973"><span class="hs-identifier hs-var hs-var">all_field_names</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(FieldLbl Name -&gt; Name) -&gt; [FieldLbl Name] -&gt; [Name]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">FieldLbl Name -&gt; Name
forall a. FieldLbl a -&gt; a
</span><a href="GHC.Types.FieldLabel.html#flSelector"><span class="hs-identifier hs-var hs-var">flSelector</span></a></span><span> </span><span class="annot"><span class="annottext">([FieldLbl Name] -&gt; [Name])
-&gt; (TyCon -&gt; [FieldLbl Name]) -&gt; TyCon -&gt; [Name]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(DataCon -&gt; [FieldLbl Name]) -&gt; [DataCon] -&gt; [FieldLbl Name]
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; [FieldLbl Name]
</span><a href="GHC.Core.DataCon.html#dataConFieldLabels"><span class="hs-identifier hs-var">dataConFieldLabels</span></a></span><span>
</span><span id="line-615"></span><span>                                     </span><span class="annot"><span class="annottext">([DataCon] -&gt; [FieldLbl Name])
-&gt; (TyCon -&gt; [DataCon]) -&gt; TyCon -&gt; [FieldLbl Name]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [DataCon]
</span><a href="GHC.Core.TyCon.html#tyConDataCons"><span class="hs-identifier hs-var">tyConDataCons</span></a></span><span>
</span><span id="line-616"></span><span>
</span><span id="line-617"></span><span class="hs-comment">{-
Note [Deriving and unused record selectors]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Consider this (see #13919):

  module Main (main) where

  data Foo = MkFoo {bar :: String} deriving Show

  main :: IO ()
  main = print (Foo &quot;hello&quot;)

Strictly speaking, the record selector `bar` is unused in this module, since
neither `main` nor the derived `Show` instance for `Foo` mention `bar`.
However, the behavior of `main` is affected by the presence of `bar`, since
it will print different output depending on whether `MkFoo` is defined using
record selectors or not. Therefore, we do not to issue a
&quot;Defined but not used: &#8216;bar&#8217;&quot; warning for this module, since removing `bar`
changes the program's behavior. This is the reason behind the [Name] part of
the return type of `hasStockDeriving`&#8212;it tracks all of the record selector
`Name`s for which -Wunused-binds should be suppressed.

Currently, the only three stock derived classes that require this are Read,
Show, and Generic, as their derived code all depend on the record selectors
of the derived data type's constructors.

See also Note [Newtype deriving and unused constructors] in GHC.Tc.Deriv for
another example of a similar trick.
-}</span><span>
</span><span id="line-646"></span><span>
</span><span id="line-647"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#getDataConFixityFun"><span class="hs-identifier hs-type">getDataConFixityFun</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Types.Name.html#Name"><span class="hs-identifier hs-type">Name</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Types.Basic.html#Fixity"><span class="hs-identifier hs-type">Fixity</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-648"></span><span class="hs-comment">-- If the TyCon is locally defined, we want the local fixity env;</span><span>
</span><span id="line-649"></span><span class="hs-comment">-- but if it is imported (which happens for standalone deriving)</span><span>
</span><span id="line-650"></span><span class="hs-comment">-- we need to get the fixity env from the interface file</span><span>
</span><span id="line-651"></span><span class="hs-comment">-- c.f. GHC.Rename.Env.lookupFixity, and #9830</span><span>
</span><span id="line-652"></span><span id="getDataConFixityFun"><span class="annot"><span class="annottext">getDataConFixityFun :: TyCon -&gt; TcM (Name -&gt; Fixity)
</span><a href="GHC.Tc.Deriv.Utils.html#getDataConFixityFun"><span class="hs-identifier hs-var hs-var">getDataConFixityFun</span></a></span></span><span> </span><span id="local-6989586621681169956"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169956"><span class="hs-identifier hs-var">tc</span></a></span></span><span>
</span><span id="line-653"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681169955"><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681169955"><span class="hs-identifier hs-var">this_mod</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">IOEnv (Env TcGblEnv TcLclEnv) Module
forall (m :: * -&gt; *). HasModule m =&gt; m Module
</span><a href="GHC.Unit.Module.html#getModule"><span class="hs-identifier hs-var">getModule</span></a></span><span>
</span><span id="line-654"></span><span>       </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Module -&gt; Name -&gt; Bool
</span><a href="GHC.Types.Name.html#nameIsLocalOrFrom"><span class="hs-identifier hs-var">nameIsLocalOrFrom</span></a></span><span> </span><span class="annot"><span class="annottext">Module
</span><a href="#local-6989586621681169955"><span class="hs-identifier hs-var">this_mod</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681169953"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-655"></span><span>         </span><span class="hs-keyword">then</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681169952"><span class="annot"><span class="annottext">FixityEnv
</span><a href="#local-6989586621681169952"><span class="hs-identifier hs-var">fix_env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRn FixityEnv
</span><a href="GHC.Tc.Utils.Monad.html#getFixityEnv"><span class="hs-identifier hs-var">getFixityEnv</span></a></span><span>
</span><span id="line-656"></span><span>                 </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; Fixity) -&gt; TcM (Name -&gt; Fixity)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">FixityEnv -&gt; Name -&gt; Fixity
</span><a href="GHC.Driver.Types.html#lookupFixity"><span class="hs-identifier hs-var">lookupFixity</span></a></span><span> </span><span class="annot"><span class="annottext">FixityEnv
</span><a href="#local-6989586621681169952"><span class="hs-identifier hs-var">fix_env</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-657"></span><span>         </span><span class="hs-keyword">else</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681169950"><span class="annot"><span class="annottext">ModIface
</span><a href="#local-6989586621681169950"><span class="hs-identifier hs-var">iface</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Name -&gt; TcRn ModIface
</span><a href="GHC.Iface.Load.html#loadInterfaceForName"><span class="hs-identifier hs-var">loadInterfaceForName</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681169949"><span class="hs-identifier hs-var">doc</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681169953"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-658"></span><span>                            </span><span class="hs-comment">-- Should already be loaded!</span><span>
</span><span id="line-659"></span><span>                 </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">(Name -&gt; Fixity) -&gt; TcM (Name -&gt; Fixity)
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModIface -&gt; OccName -&gt; Fixity
</span><a href="GHC.Driver.Types.html#mi_fix"><span class="hs-identifier hs-var">mi_fix</span></a></span><span> </span><span class="annot"><span class="annottext">ModIface
</span><a href="#local-6989586621681169950"><span class="hs-identifier hs-var">iface</span></a></span><span> </span><span class="annot"><span class="annottext">(OccName -&gt; Fixity) -&gt; (Name -&gt; OccName) -&gt; Name -&gt; Fixity
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; OccName
</span><a href="GHC.Types.Name.html#nameOccName"><span class="hs-identifier hs-var">nameOccName</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">}</span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-660"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-661"></span><span>    </span><span id="local-6989586621681169953"><span class="annot"><span class="annottext">name :: Name
</span><a href="#local-6989586621681169953"><span class="hs-identifier hs-var hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Name
</span><a href="GHC.Core.TyCon.html#tyConName"><span class="hs-identifier hs-var hs-var">tyConName</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169956"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-662"></span><span>    </span><span id="local-6989586621681169949"><span class="annot"><span class="annottext">doc :: SDoc
</span><a href="#local-6989586621681169949"><span class="hs-identifier hs-var hs-var">doc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Data con fixities for&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">Name -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681169953"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-663"></span><span>
</span><span id="line-664"></span><span class="hs-comment">------------------------------------------------------------------</span><span>
</span><span id="line-665"></span><span class="hs-comment">-- Check side conditions that dis-allow derivability for the originative</span><span>
</span><span id="line-666"></span><span class="hs-comment">-- deriving strategies (stock and anyclass).</span><span>
</span><span id="line-667"></span><span class="hs-comment">-- See Note [Deriving strategies] in GHC.Tc.Deriv for an explanation of what</span><span>
</span><span id="line-668"></span><span class="hs-comment">-- &quot;originative&quot; means.</span><span>
</span><span id="line-669"></span><span class="hs-comment">--</span><span>
</span><span id="line-670"></span><span class="hs-comment">-- This is *apart* from the coerce-based strategies, newtype and via.</span><span>
</span><span id="line-671"></span><span class="hs-comment">--</span><span>
</span><span id="line-672"></span><span class="hs-comment">-- Here we get the representation tycon in case of family instances as it has</span><span>
</span><span id="line-673"></span><span class="hs-comment">-- the data constructors - but we need to be careful to fall back to the</span><span>
</span><span id="line-674"></span><span class="hs-comment">-- family tycon (with indexes) in error messages.</span><span>
</span><span id="line-675"></span><span>
</span><span id="line-676"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#checkOriginativeSideConditions"><span class="hs-identifier hs-type">checkOriginativeSideConditions</span></a></span><span>
</span><span id="line-677"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivContext"><span class="hs-identifier hs-type">DerivContext</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Tc.Utils.TcType.html#TcType"><span class="hs-identifier hs-type">TcType</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-678"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span>
</span><span id="line-679"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#OriginativeDerivStatus"><span class="hs-identifier hs-type">OriginativeDerivStatus</span></a></span><span>
</span><span id="line-680"></span><span id="checkOriginativeSideConditions"><span class="annot"><span class="annottext">checkOriginativeSideConditions :: DynFlags
-&gt; DerivContext
-&gt; Class
-&gt; [Type]
-&gt; TyCon
-&gt; TyCon
-&gt; OriginativeDerivStatus
</span><a href="GHC.Tc.Deriv.Utils.html#checkOriginativeSideConditions"><span class="hs-identifier hs-var hs-var">checkOriginativeSideConditions</span></a></span></span><span> </span><span id="local-6989586621681169945"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681169945"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681169944"><span class="annot"><span class="annottext">DerivContext
</span><a href="#local-6989586621681169944"><span class="hs-identifier hs-var">deriv_ctxt</span></a></span></span><span> </span><span id="local-6989586621681169943"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169943"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span id="local-6989586621681169942"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681169942"><span class="hs-identifier hs-var">cls_tys</span></a></span></span><span> </span><span id="local-6989586621681169941"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169941"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span id="local-6989586621681169940"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169940"><span class="hs-identifier hs-var">rep_tc</span></a></span></span><span>
</span><span id="line-681"></span><span>    </span><span class="hs-comment">-- First, check if stock deriving is possible...</span><span>
</span><span id="line-682"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681169939"><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169939"><span class="hs-identifier hs-var">cond</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DerivContext -&gt; Class -&gt; Maybe Condition
</span><a href="GHC.Tc.Deriv.Utils.html#stockSideConditions"><span class="hs-identifier hs-var">stockSideConditions</span></a></span><span> </span><span class="annot"><span class="annottext">DerivContext
</span><a href="#local-6989586621681169944"><span class="hs-identifier hs-var">deriv_ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169943"><span class="hs-identifier hs-var">cls</span></a></span><span>
</span><span id="line-683"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169939"><span class="hs-identifier hs-var">cond</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681169945"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169941"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169940"><span class="hs-identifier hs-var">rep_tc</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-684"></span><span>        </span><span class="annot"><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-type">NotValid</span></a></span><span> </span><span id="local-6989586621681169936"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681169936"><span class="hs-identifier hs-var">err</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; OriginativeDerivStatus
</span><a href="GHC.Tc.Deriv.Utils.html#StockClassError"><span class="hs-identifier hs-var">StockClassError</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681169936"><span class="hs-identifier hs-var">err</span></a></span><span>  </span><span class="hs-comment">-- Class-specific error</span><span>
</span><span id="line-685"></span><span>        </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; [Type] -&gt; [Type]
</span><a href="GHC.Core.Type.html#filterOutInvisibleTypes"><span class="hs-identifier hs-var">filterOutInvisibleTypes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; TyCon
</span><a href="GHC.Core.Class.html#classTyCon"><span class="hs-identifier hs-var hs-var">classTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169943"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681169942"><span class="hs-identifier hs-var">cls_tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-686"></span><span>                   </span><span class="hs-comment">-- All stock derivable classes are unary in the sense that</span><span>
</span><span id="line-687"></span><span>                   </span><span class="hs-comment">-- there should be not types in cls_tys (i.e., no type args</span><span>
</span><span id="line-688"></span><span>                   </span><span class="hs-comment">-- other than last). Note that cls_types can contain</span><span>
</span><span id="line-689"></span><span>                   </span><span class="hs-comment">-- invisible types as well (e.g., for Generic1, which is</span><span>
</span><span id="line-690"></span><span>                   </span><span class="hs-comment">-- poly-kinded), so make sure those are not counted.</span><span>
</span><span id="line-691"></span><span>                 </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681169931"><span class="annot"><span class="annottext">SrcSpan
-&gt; TyCon -&gt; [Type] -&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name])
</span><a href="#local-6989586621681169931"><span class="hs-identifier hs-var">gen_fn</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Class
-&gt; Maybe
     (SrcSpan
      -&gt; TyCon -&gt; [Type] -&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name]))
</span><a href="GHC.Tc.Deriv.Utils.html#hasStockDeriving"><span class="hs-identifier hs-var">hasStockDeriving</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169943"><span class="hs-identifier hs-var">cls</span></a></span><span>
</span><span id="line-692"></span><span>                   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(SrcSpan
 -&gt; TyCon -&gt; [Type] -&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name]))
-&gt; OriginativeDerivStatus
</span><a href="GHC.Tc.Deriv.Utils.html#CanDeriveStock"><span class="hs-identifier hs-var">CanDeriveStock</span></a></span><span> </span><span class="annot"><span class="annottext">SrcSpan
-&gt; TyCon -&gt; [Type] -&gt; TcM (LHsBinds GhcPs, BagDerivStuff, [Name])
</span><a href="#local-6989586621681169931"><span class="hs-identifier hs-var">gen_fn</span></a></span><span>
</span><span id="line-693"></span><span>                 </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; OriginativeDerivStatus
</span><a href="GHC.Tc.Deriv.Utils.html#StockClassError"><span class="hs-identifier hs-var">StockClassError</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; [Type] -&gt; SDoc
</span><a href="GHC.Tc.Deriv.Utils.html#classArgsErr"><span class="hs-identifier hs-var">classArgsErr</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169943"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681169942"><span class="hs-identifier hs-var">cls_tys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-694"></span><span>                   </span><span class="hs-comment">-- e.g. deriving( Eq s )</span><span>
</span><span id="line-695"></span><span>
</span><span id="line-696"></span><span>    </span><span class="hs-comment">-- ...if not, try falling back on DeriveAnyClass.</span><span>
</span><span id="line-697"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-type">NotValid</span></a></span><span> </span><span id="local-6989586621681169929"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681169929"><span class="hs-identifier hs-var">err</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DynFlags -&gt; Validity
</span><a href="GHC.Tc.Deriv.Utils.html#canDeriveAnyClass"><span class="hs-identifier hs-var">canDeriveAnyClass</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681169945"><span class="hs-identifier hs-var">dflags</span></a></span><span>
</span><span id="line-698"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; OriginativeDerivStatus
</span><a href="GHC.Tc.Deriv.Utils.html#NonDerivableClass"><span class="hs-identifier hs-var">NonDerivableClass</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681169929"><span class="hs-identifier hs-var">err</span></a></span><span>  </span><span class="hs-comment">-- Neither anyclass nor stock work</span><span>
</span><span id="line-699"></span><span>
</span><span id="line-700"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-701"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">OriginativeDerivStatus
</span><a href="GHC.Tc.Deriv.Utils.html#CanDeriveAnyClass"><span class="hs-identifier hs-var">CanDeriveAnyClass</span></a></span><span>   </span><span class="hs-comment">-- DeriveAnyClass should work</span><span>
</span><span id="line-702"></span><span>
</span><span id="line-703"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#classArgsErr"><span class="hs-identifier hs-type">classArgsErr</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-704"></span><span id="classArgsErr"><span class="annot"><span class="annottext">classArgsErr :: Class -&gt; [Type] -&gt; SDoc
</span><a href="GHC.Tc.Deriv.Utils.html#classArgsErr"><span class="hs-identifier hs-var hs-var">classArgsErr</span></a></span></span><span> </span><span id="local-6989586621681169928"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169928"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span id="local-6989586621681169927"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681169927"><span class="hs-identifier hs-var">cls_tys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; [Type] -&gt; Type
</span><a href="GHC.Core.Predicate.html#mkClassPred"><span class="hs-identifier hs-var">mkClassPred</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169928"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681169927"><span class="hs-identifier hs-var">cls_tys</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;is not a class&quot;</span></span><span>
</span><span id="line-705"></span><span>
</span><span id="line-706"></span><span class="hs-comment">-- Side conditions (whether the datatype must have at least one constructor,</span><span>
</span><span id="line-707"></span><span class="hs-comment">-- required language extensions, etc.) for using GHC's stock deriving</span><span>
</span><span id="line-708"></span><span class="hs-comment">-- mechanism on certain classes (as opposed to classes that require</span><span>
</span><span id="line-709"></span><span class="hs-comment">-- GeneralizedNewtypeDeriving or DeriveAnyClass). Returns Nothing for a</span><span>
</span><span id="line-710"></span><span class="hs-comment">-- class for which stock deriving isn't possible.</span><span>
</span><span id="line-711"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#stockSideConditions"><span class="hs-identifier hs-type">stockSideConditions</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivContext"><span class="hs-identifier hs-type">DerivContext</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#Condition"><span class="hs-identifier hs-type">Condition</span></a></span><span>
</span><span id="line-712"></span><span id="stockSideConditions"><span class="annot"><span class="annottext">stockSideConditions :: DerivContext -&gt; Class -&gt; Maybe Condition
</span><a href="GHC.Tc.Deriv.Utils.html#stockSideConditions"><span class="hs-identifier hs-var hs-var">stockSideConditions</span></a></span></span><span> </span><span id="local-6989586621681169924"><span class="annot"><span class="annottext">DerivContext
</span><a href="#local-6989586621681169924"><span class="hs-identifier hs-var">deriv_ctxt</span></a></span></span><span> </span><span id="local-6989586621681169923"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169923"><span class="hs-identifier hs-var">cls</span></a></span></span><span>
</span><span id="line-713"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681169922"><span class="hs-identifier hs-var">cls_key</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Unique -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#eqClassKey"><span class="hs-identifier hs-var">eqClassKey</span></a></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Maybe Condition
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169921"><span class="hs-identifier hs-var">cond_std</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-operator hs-var">`andCond`</span></a></span><span> </span><span class="annot"><span class="annottext">Class -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_args"><span class="hs-identifier hs-var">cond_args</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169923"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-714"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681169922"><span class="hs-identifier hs-var">cls_key</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Unique -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#ordClassKey"><span class="hs-identifier hs-var">ordClassKey</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Maybe Condition
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169921"><span class="hs-identifier hs-var">cond_std</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-operator hs-var">`andCond`</span></a></span><span> </span><span class="annot"><span class="annottext">Class -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_args"><span class="hs-identifier hs-var">cond_args</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169923"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-715"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681169922"><span class="hs-identifier hs-var">cls_key</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Unique -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#showClassKey"><span class="hs-identifier hs-var">showClassKey</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Maybe Condition
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169921"><span class="hs-identifier hs-var">cond_std</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-operator hs-var">`andCond`</span></a></span><span> </span><span class="annot"><span class="annottext">Class -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_args"><span class="hs-identifier hs-var">cond_args</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169923"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-716"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681169922"><span class="hs-identifier hs-var">cls_key</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Unique -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#readClassKey"><span class="hs-identifier hs-var">readClassKey</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Maybe Condition
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169921"><span class="hs-identifier hs-var">cond_std</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-operator hs-var">`andCond`</span></a></span><span> </span><span class="annot"><span class="annottext">Class -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_args"><span class="hs-identifier hs-var">cond_args</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169923"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-717"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681169922"><span class="hs-identifier hs-var">cls_key</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Unique -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#enumClassKey"><span class="hs-identifier hs-var">enumClassKey</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Maybe Condition
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169921"><span class="hs-identifier hs-var">cond_std</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-operator hs-var">`andCond`</span></a></span><span> </span><span class="annot"><span class="annottext">Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_isEnumeration"><span class="hs-identifier hs-var">cond_isEnumeration</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-718"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681169922"><span class="hs-identifier hs-var">cls_key</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Unique -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#ixClassKey"><span class="hs-identifier hs-var">ixClassKey</span></a></span><span>          </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Maybe Condition
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169921"><span class="hs-identifier hs-var">cond_std</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-operator hs-var">`andCond`</span></a></span><span> </span><span class="annot"><span class="annottext">Class -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_enumOrProduct"><span class="hs-identifier hs-var">cond_enumOrProduct</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169923"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-719"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681169922"><span class="hs-identifier hs-var">cls_key</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Unique -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#boundedClassKey"><span class="hs-identifier hs-var">boundedClassKey</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Maybe Condition
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169921"><span class="hs-identifier hs-var">cond_std</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-operator hs-var">`andCond`</span></a></span><span> </span><span class="annot"><span class="annottext">Class -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_enumOrProduct"><span class="hs-identifier hs-var">cond_enumOrProduct</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169923"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-720"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681169922"><span class="hs-identifier hs-var">cls_key</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Unique -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#dataClassKey"><span class="hs-identifier hs-var">dataClassKey</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Maybe Condition
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Extension -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#checkFlag"><span class="hs-identifier hs-var">checkFlag</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#DeriveDataTypeable"><span class="hs-identifier hs-var">LangExt.DeriveDataTypeable</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-operator hs-var">`andCond`</span></a></span><span>
</span><span id="line-721"></span><span>                                           </span><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169914"><span class="hs-identifier hs-var">cond_vanilla</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-operator hs-var">`andCond`</span></a></span><span>
</span><span id="line-722"></span><span>                                           </span><span class="annot"><span class="annottext">Class -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_args"><span class="hs-identifier hs-var">cond_args</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169923"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-723"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681169922"><span class="hs-identifier hs-var">cls_key</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Unique -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#functorClassKey"><span class="hs-identifier hs-var">functorClassKey</span></a></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Maybe Condition
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Extension -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#checkFlag"><span class="hs-identifier hs-var">checkFlag</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#DeriveFunctor"><span class="hs-identifier hs-var">LangExt.DeriveFunctor</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-operator hs-var">`andCond`</span></a></span><span>
</span><span id="line-724"></span><span>                                           </span><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169914"><span class="hs-identifier hs-var">cond_vanilla</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-operator hs-var">`andCond`</span></a></span><span>
</span><span id="line-725"></span><span>                                           </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_functorOK"><span class="hs-identifier hs-var">cond_functorOK</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span>
</span><span id="line-726"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681169922"><span class="hs-identifier hs-var">cls_key</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Unique -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#foldableClassKey"><span class="hs-identifier hs-var">foldableClassKey</span></a></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Maybe Condition
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Extension -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#checkFlag"><span class="hs-identifier hs-var">checkFlag</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#DeriveFoldable"><span class="hs-identifier hs-var">LangExt.DeriveFoldable</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-operator hs-var">`andCond`</span></a></span><span>
</span><span id="line-727"></span><span>                                           </span><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169914"><span class="hs-identifier hs-var">cond_vanilla</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-operator hs-var">`andCond`</span></a></span><span>
</span><span id="line-728"></span><span>                                           </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_functorOK"><span class="hs-identifier hs-var">cond_functorOK</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span class="hs-special">)</span><span>
</span><span id="line-729"></span><span>                                           </span><span class="hs-comment">-- Functor/Fold/Trav works ok</span><span>
</span><span id="line-730"></span><span>                                           </span><span class="hs-comment">-- for rank-n types</span><span>
</span><span id="line-731"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681169922"><span class="hs-identifier hs-var">cls_key</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Unique -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#traversableClassKey"><span class="hs-identifier hs-var">traversableClassKey</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Maybe Condition
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Extension -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#checkFlag"><span class="hs-identifier hs-var">checkFlag</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#DeriveTraversable"><span class="hs-identifier hs-var">LangExt.DeriveTraversable</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-operator hs-var">`andCond`</span></a></span><span>
</span><span id="line-732"></span><span>                                           </span><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169914"><span class="hs-identifier hs-var">cond_vanilla</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-operator hs-var">`andCond`</span></a></span><span>
</span><span id="line-733"></span><span>                                           </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_functorOK"><span class="hs-identifier hs-var">cond_functorOK</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span class="hs-special">)</span><span>
</span><span id="line-734"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681169922"><span class="hs-identifier hs-var">cls_key</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Unique -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#genClassKey"><span class="hs-identifier hs-var">genClassKey</span></a></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Maybe Condition
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Extension -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#checkFlag"><span class="hs-identifier hs-var">checkFlag</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#DeriveGeneric"><span class="hs-identifier hs-var">LangExt.DeriveGeneric</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-operator hs-var">`andCond`</span></a></span><span>
</span><span id="line-735"></span><span>                                           </span><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169914"><span class="hs-identifier hs-var">cond_vanilla</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-operator hs-var">`andCond`</span></a></span><span>
</span><span id="line-736"></span><span>                                           </span><span class="annot"><span class="annottext">Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_RepresentableOk"><span class="hs-identifier hs-var">cond_RepresentableOk</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-737"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681169922"><span class="hs-identifier hs-var">cls_key</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Unique -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#gen1ClassKey"><span class="hs-identifier hs-var">gen1ClassKey</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Maybe Condition
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Extension -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#checkFlag"><span class="hs-identifier hs-var">checkFlag</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#DeriveGeneric"><span class="hs-identifier hs-var">LangExt.DeriveGeneric</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-operator hs-var">`andCond`</span></a></span><span>
</span><span id="line-738"></span><span>                                           </span><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169914"><span class="hs-identifier hs-var">cond_vanilla</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-operator hs-var">`andCond`</span></a></span><span>
</span><span id="line-739"></span><span>                                           </span><span class="annot"><span class="annottext">Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_Representable1Ok"><span class="hs-identifier hs-var">cond_Representable1Ok</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-740"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681169922"><span class="hs-identifier hs-var">cls_key</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Unique -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.TH.html#liftClassKey"><span class="hs-identifier hs-var">liftClassKey</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Maybe Condition
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Extension -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#checkFlag"><span class="hs-identifier hs-var">checkFlag</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#DeriveLift"><span class="hs-identifier hs-var">LangExt.DeriveLift</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-operator hs-var">`andCond`</span></a></span><span>
</span><span id="line-741"></span><span>                                           </span><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169914"><span class="hs-identifier hs-var">cond_vanilla</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-operator hs-var">`andCond`</span></a></span><span>
</span><span id="line-742"></span><span>                                           </span><span class="annot"><span class="annottext">Class -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_args"><span class="hs-identifier hs-var">cond_args</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169923"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-743"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe Condition
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-744"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-745"></span><span>    </span><span id="local-6989586621681169922"><span class="annot"><span class="annottext">cls_key :: Unique
</span><a href="#local-6989586621681169922"><span class="hs-identifier hs-var hs-var">cls_key</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Class -&gt; Unique
forall a. Uniquable a =&gt; a -&gt; Unique
</span><a href="GHC.Types.Unique.html#getUnique"><span class="hs-identifier hs-var">getUnique</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169923"><span class="hs-identifier hs-var">cls</span></a></span><span>
</span><span id="line-746"></span><span>    </span><span id="local-6989586621681169921"><span class="annot"><span class="annottext">cond_std :: Condition
</span><a href="#local-6989586621681169921"><span class="hs-identifier hs-var hs-var">cond_std</span></a></span></span><span>     </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DerivContext -&gt; Bool -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_stdOK"><span class="hs-identifier hs-var">cond_stdOK</span></a></span><span> </span><span class="annot"><span class="annottext">DerivContext
</span><a href="#local-6989586621681169924"><span class="hs-identifier hs-var">deriv_ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>
</span><span id="line-747"></span><span>      </span><span class="hs-comment">-- Vanilla data constructors, at least one, and monotype arguments</span><span>
</span><span id="line-748"></span><span>    </span><span id="local-6989586621681169914"><span class="annot"><span class="annottext">cond_vanilla :: Condition
</span><a href="#local-6989586621681169914"><span class="hs-identifier hs-var hs-var">cond_vanilla</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DerivContext -&gt; Bool -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_stdOK"><span class="hs-identifier hs-var">cond_stdOK</span></a></span><span> </span><span class="annot"><span class="annottext">DerivContext
</span><a href="#local-6989586621681169924"><span class="hs-identifier hs-var">deriv_ctxt</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-749"></span><span>      </span><span class="hs-comment">-- Vanilla data constructors but allow no data cons or polytype arguments</span><span>
</span><span id="line-750"></span><span>
</span><span id="line-751"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#canDeriveAnyClass"><span class="hs-identifier hs-type">canDeriveAnyClass</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#Validity"><span class="hs-identifier hs-type">Validity</span></a></span><span>
</span><span id="line-752"></span><span class="hs-comment">-- IsValid: we can (try to) derive it via an empty instance declaration</span><span>
</span><span id="line-753"></span><span class="hs-comment">-- NotValid s:  we can't, reason s</span><span>
</span><span id="line-754"></span><span id="canDeriveAnyClass"><span class="annot"><span class="annottext">canDeriveAnyClass :: DynFlags -&gt; Validity
</span><a href="GHC.Tc.Deriv.Utils.html#canDeriveAnyClass"><span class="hs-identifier hs-var hs-var">canDeriveAnyClass</span></a></span></span><span> </span><span id="local-6989586621681169904"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681169904"><span class="hs-identifier hs-var">dflags</span></a></span></span><span>
</span><span id="line-755"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Extension -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#xopt"><span class="hs-identifier hs-var">xopt</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#DeriveAnyClass"><span class="hs-identifier hs-var">LangExt.DeriveAnyClass</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681169904"><span class="hs-identifier hs-var">dflags</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-756"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Validity
</span><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-var">NotValid</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Try enabling DeriveAnyClass&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-757"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-758"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span>   </span><span class="hs-comment">-- OK!</span><span>
</span><span id="line-759"></span><span>
</span><span id="line-760"></span><span class="hs-keyword">type</span><span> </span><span id="Condition"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#Condition"><span class="hs-identifier hs-var">Condition</span></a></span></span><span>
</span><span id="line-761"></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="GHC.Driver.Session.html#DynFlags"><span class="hs-identifier hs-type">DynFlags</span></a></span><span>
</span><span id="line-762"></span><span>
</span><span id="line-763"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span>    </span><span class="hs-comment">-- ^ The data type's 'TyCon'. For data families, this is the</span><span>
</span><span id="line-764"></span><span>              </span><span class="hs-comment">-- family 'TyCon'.</span><span>
</span><span id="line-765"></span><span>
</span><span id="line-766"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span>    </span><span class="hs-comment">-- ^ For data families, this is the representation 'TyCon'.</span><span>
</span><span id="line-767"></span><span>              </span><span class="hs-comment">-- Otherwise, this is the same as the other 'TyCon' argument.</span><span>
</span><span id="line-768"></span><span>
</span><span id="line-769"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#Validity"><span class="hs-identifier hs-type">Validity</span></a></span><span> </span><span class="hs-comment">-- ^ 'IsValid' if deriving an instance for this 'TyCon' is</span><span>
</span><span id="line-770"></span><span>              </span><span class="hs-comment">-- possible. Otherwise, it's @'NotValid' err@, where @err@</span><span>
</span><span id="line-771"></span><span>              </span><span class="hs-comment">-- explains what went wrong.</span><span>
</span><span id="line-772"></span><span>
</span><span id="line-773"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#orCond"><span class="hs-identifier hs-type">orCond</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#Condition"><span class="hs-identifier hs-type">Condition</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#Condition"><span class="hs-identifier hs-type">Condition</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#Condition"><span class="hs-identifier hs-type">Condition</span></a></span><span>
</span><span id="line-774"></span><span id="orCond"><span class="annot"><span class="annottext">orCond :: Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#orCond"><span class="hs-identifier hs-var hs-var">orCond</span></a></span></span><span> </span><span id="local-6989586621681169899"><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169899"><span class="hs-identifier hs-var">c1</span></a></span></span><span> </span><span id="local-6989586621681169898"><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169898"><span class="hs-identifier hs-var">c2</span></a></span></span><span> </span><span id="local-6989586621681169897"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681169897"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681169896"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169896"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span id="local-6989586621681169895"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169895"><span class="hs-identifier hs-var">rep_tc</span></a></span></span><span>
</span><span id="line-775"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169899"><span class="hs-identifier hs-var">c1</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681169897"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169896"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169895"><span class="hs-identifier hs-var">rep_tc</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169898"><span class="hs-identifier hs-var">c2</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681169897"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169896"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169895"><span class="hs-identifier hs-var">rep_tc</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-776"></span><span>     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span class="hs-special">,</span><span>    </span><span class="annot"><span class="annottext">Validity
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span>    </span><span class="hs-comment">-- c1 succeeds</span><span>
</span><span id="line-777"></span><span>     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Validity
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span>          </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span class="hs-special">)</span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span>    </span><span class="hs-comment">-- c21 succeeds</span><span>
</span><span id="line-778"></span><span>     </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-type">NotValid</span></a></span><span> </span><span id="local-6989586621681169894"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681169894"><span class="hs-identifier hs-var">x</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-type">NotValid</span></a></span><span> </span><span id="local-6989586621681169893"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681169893"><span class="hs-identifier hs-var">y</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Validity
</span><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-var">NotValid</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681169894"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;  or&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681169893"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-779"></span><span>                                            </span><span class="hs-comment">-- Both fail</span><span>
</span><span id="line-780"></span><span>
</span><span id="line-781"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-identifier hs-type">andCond</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#Condition"><span class="hs-identifier hs-type">Condition</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#Condition"><span class="hs-identifier hs-type">Condition</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#Condition"><span class="hs-identifier hs-type">Condition</span></a></span><span>
</span><span id="line-782"></span><span id="andCond"><span class="annot"><span class="annottext">andCond :: Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-identifier hs-var hs-var">andCond</span></a></span></span><span> </span><span id="local-6989586621681169891"><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169891"><span class="hs-identifier hs-var">c1</span></a></span></span><span> </span><span id="local-6989586621681169890"><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169890"><span class="hs-identifier hs-var">c2</span></a></span></span><span> </span><span id="local-6989586621681169889"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681169889"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681169888"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169888"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span id="local-6989586621681169887"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169887"><span class="hs-identifier hs-var">rep_tc</span></a></span></span><span>
</span><span id="line-783"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169891"><span class="hs-identifier hs-var">c1</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681169889"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169888"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169887"><span class="hs-identifier hs-var">rep_tc</span></a></span><span> </span><span class="annot"><span class="annottext">Validity -&gt; Validity -&gt; Validity
</span><a href="GHC.Utils.Error.html#andValid"><span class="hs-operator hs-var">`andValid`</span></a></span><span> </span><span class="annot"><span class="annottext">Condition
</span><a href="#local-6989586621681169890"><span class="hs-identifier hs-var">c2</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681169889"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169888"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169887"><span class="hs-identifier hs-var">rep_tc</span></a></span><span>
</span><span id="line-784"></span><span>
</span><span id="line-785"></span><span class="hs-comment">-- | Some common validity checks shared among stock derivable classes. One</span><span>
</span><span id="line-786"></span><span class="hs-comment">-- check that absolutely must hold is that if an instance @C (T a)@ is being</span><span>
</span><span id="line-787"></span><span class="hs-comment">-- derived, then @T@ must be a tycon for a data type or a newtype. The</span><span>
</span><span id="line-788"></span><span class="hs-comment">-- remaining checks are only performed if using a @deriving@ clause (i.e.,</span><span>
</span><span id="line-789"></span><span class="hs-comment">-- they're ignored if using @StandaloneDeriving@):</span><span>
</span><span id="line-790"></span><span class="hs-comment">--</span><span>
</span><span id="line-791"></span><span class="hs-comment">-- 1. The data type must have at least one constructor (this check is ignored</span><span>
</span><span id="line-792"></span><span class="hs-comment">--    if using @EmptyDataDeriving@).</span><span>
</span><span id="line-793"></span><span class="hs-comment">--</span><span>
</span><span id="line-794"></span><span class="hs-comment">-- 2. The data type cannot have any GADT constructors.</span><span>
</span><span id="line-795"></span><span class="hs-comment">--</span><span>
</span><span id="line-796"></span><span class="hs-comment">-- 3. The data type cannot have any constructors with existentially quantified</span><span>
</span><span id="line-797"></span><span class="hs-comment">--    type variables.</span><span>
</span><span id="line-798"></span><span class="hs-comment">--</span><span>
</span><span id="line-799"></span><span class="hs-comment">-- 4. The data type cannot have a context (e.g., @data Foo a = Eq a =&gt; MkFoo@).</span><span>
</span><span id="line-800"></span><span class="hs-comment">--</span><span>
</span><span id="line-801"></span><span class="hs-comment">-- 5. The data type cannot have fields with higher-rank types.</span><span>
</span><span id="line-802"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#cond_stdOK"><span class="hs-identifier hs-type">cond_stdOK</span></a></span><span>
</span><span id="line-803"></span><span>  </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivContext"><span class="hs-identifier hs-type">DerivContext</span></a></span><span> </span><span class="hs-comment">-- ^ 'SupplyContext' if this is standalone deriving with a</span><span>
</span><span id="line-804"></span><span>                  </span><span class="hs-comment">-- user-supplied context, 'InferContext' if not.</span><span>
</span><span id="line-805"></span><span>                  </span><span class="hs-comment">-- If it is the former, we relax some of the validity checks</span><span>
</span><span id="line-806"></span><span>                  </span><span class="hs-comment">-- we would otherwise perform (i.e., &quot;just go for it&quot;).</span><span>
</span><span id="line-807"></span><span>
</span><span id="line-808"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>         </span><span class="hs-comment">-- ^ 'True' &lt;=&gt; allow higher rank arguments and empty data</span><span>
</span><span id="line-809"></span><span>                  </span><span class="hs-comment">-- types (with no data constructors) even in the absence of</span><span>
</span><span id="line-810"></span><span>                  </span><span class="hs-comment">-- the -XEmptyDataDeriving extension.</span><span>
</span><span id="line-811"></span><span>
</span><span id="line-812"></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#Condition"><span class="hs-identifier hs-type">Condition</span></a></span><span>
</span><span id="line-813"></span><span id="cond_stdOK"><span class="annot"><span class="annottext">cond_stdOK :: DerivContext -&gt; Bool -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_stdOK"><span class="hs-identifier hs-var hs-var">cond_stdOK</span></a></span></span><span> </span><span id="local-6989586621681169885"><span class="annot"><span class="annottext">DerivContext
</span><a href="#local-6989586621681169885"><span class="hs-identifier hs-var">deriv_ctxt</span></a></span></span><span> </span><span id="local-6989586621681169884"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681169884"><span class="hs-identifier hs-var">permissive</span></a></span></span><span> </span><span id="local-6989586621681169883"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681169883"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span id="local-6989586621681169882"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169882"><span class="hs-identifier hs-var">tc</span></a></span></span><span> </span><span id="local-6989586621681169881"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169881"><span class="hs-identifier hs-var">rep_tc</span></a></span></span><span>
</span><span id="line-814"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="#local-6989586621681169880"><span class="hs-identifier hs-var">valid_ADT</span></a></span><span> </span><span class="annot"><span class="annottext">Validity -&gt; Validity -&gt; Validity
</span><a href="GHC.Utils.Error.html#andValid"><span class="hs-operator hs-var">`andValid`</span></a></span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="#local-6989586621681169879"><span class="hs-identifier hs-var">valid_misc</span></a></span><span>
</span><span id="line-815"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-816"></span><span>    </span><span class="annot"><a href="#local-6989586621681169880"><span class="hs-identifier hs-type">valid_ADT</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="#local-6989586621681169879"><span class="hs-identifier hs-type">valid_misc</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#Validity"><span class="hs-identifier hs-type">Validity</span></a></span><span>
</span><span id="line-817"></span><span>    </span><span id="local-6989586621681169880"><span class="annot"><span class="annottext">valid_ADT :: Validity
</span><a href="#local-6989586621681169880"><span class="hs-identifier hs-var hs-var">valid_ADT</span></a></span></span><span>
</span><span id="line-818"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isAlgTyCon"><span class="hs-identifier hs-var">isAlgTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169882"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isDataFamilyTyCon"><span class="hs-identifier hs-var">isDataFamilyTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169882"><span class="hs-identifier hs-var">tc</span></a></span><span>
</span><span id="line-819"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span>
</span><span id="line-820"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-821"></span><span>        </span><span class="hs-comment">-- Complain about functions, primitive types, and other tycons that</span><span>
</span><span id="line-822"></span><span>        </span><span class="hs-comment">-- stock deriving can't handle.</span><span>
</span><span id="line-823"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Validity
</span><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-var">NotValid</span></a></span><span> </span><span class="annot"><span class="annottext">(SDoc -&gt; Validity) -&gt; SDoc -&gt; Validity
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;The last argument of the instance must be a&quot;</span></span><span>
</span><span id="line-824"></span><span>               </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;data or newtype application&quot;</span></span><span>
</span><span id="line-825"></span><span>
</span><span id="line-826"></span><span>    </span><span id="local-6989586621681169879"><span class="annot"><span class="annottext">valid_misc :: Validity
</span><a href="#local-6989586621681169879"><span class="hs-identifier hs-var hs-var">valid_misc</span></a></span></span><span>
</span><span id="line-827"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">DerivContext
</span><a href="#local-6989586621681169885"><span class="hs-identifier hs-var">deriv_ctxt</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-828"></span><span>         </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#SupplyContext"><span class="hs-identifier hs-type">SupplyContext</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span>
</span><span id="line-829"></span><span>                </span><span class="hs-comment">-- Don't check these conservative conditions for</span><span>
</span><span id="line-830"></span><span>                </span><span class="hs-comment">-- standalone deriving; just generate the code</span><span>
</span><span id="line-831"></span><span>                </span><span class="hs-comment">-- and let the typechecker handle the result</span><span>
</span><span id="line-832"></span><span>         </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#InferContext"><span class="hs-identifier hs-type">InferContext</span></a></span><span> </span><span id="local-6989586621681169875"><span class="annot"><span class="annottext">Maybe SrcSpan
</span><a href="#local-6989586621681169875"><span class="hs-identifier hs-var">wildcard</span></a></span></span><span>
</span><span id="line-833"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[DataCon] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[DataCon]
</span><a href="#local-6989586621681169874"><span class="hs-identifier hs-var">data_cons</span></a></span><span> </span><span class="hs-comment">-- 1.</span><span>
</span><span id="line-834"></span><span>           </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681169884"><span class="hs-identifier hs-var">permissive</span></a></span><span>
</span><span id="line-835"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Extension -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#checkFlag"><span class="hs-identifier hs-var">checkFlag</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#EmptyDataDeriving"><span class="hs-identifier hs-var">LangExt.EmptyDataDeriving</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681169883"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169882"><span class="hs-identifier hs-var">tc</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169881"><span class="hs-identifier hs-var">rep_tc</span></a></span><span> </span><span class="annot"><span class="annottext">Validity -&gt; Validity -&gt; Validity
</span><a href="GHC.Utils.Error.html#orValid"><span class="hs-operator hs-var">`orValid`</span></a></span><span>
</span><span id="line-836"></span><span>              </span><span class="annot"><span class="annottext">SDoc -&gt; Validity
</span><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-var">NotValid</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
</span><a href="GHC.Tc.Deriv.Utils.html#no_cons_why"><span class="hs-identifier hs-var">no_cons_why</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169881"><span class="hs-identifier hs-var">rep_tc</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681169870"><span class="hs-identifier hs-var">empty_data_suggestion</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-837"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[SDoc]
</span><a href="#local-6989586621681169869"><span class="hs-identifier hs-var">con_whys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-838"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Validity
</span><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-var">NotValid</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#vcat"><span class="hs-identifier hs-var">vcat</span></a></span><span> </span><span class="annot"><span class="annottext">[SDoc]
</span><a href="#local-6989586621681169869"><span class="hs-identifier hs-var">con_whys</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%24%24"><span class="hs-operator hs-var">$$</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe SrcSpan -&gt; SDoc
forall {a}. Maybe a -&gt; SDoc
</span><a href="#local-6989586621681169868"><span class="hs-identifier hs-var">possible_fix_suggestion</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe SrcSpan
</span><a href="#local-6989586621681169875"><span class="hs-identifier hs-var">wildcard</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-839"></span><span>           </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-840"></span><span>           </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span>
</span><span id="line-841"></span><span>
</span><span id="line-842"></span><span>    </span><span id="local-6989586621681169870"><span class="annot"><span class="annottext">empty_data_suggestion :: SDoc
</span><a href="#local-6989586621681169870"><span class="hs-identifier hs-var hs-var">empty_data_suggestion</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-843"></span><span>      </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Use EmptyDataDeriving to enable deriving for empty data types&quot;</span></span><span>
</span><span id="line-844"></span><span>    </span><span id="local-6989586621681169868"><span class="annot"><span class="annottext">possible_fix_suggestion :: Maybe a -&gt; SDoc
</span><a href="#local-6989586621681169868"><span class="hs-identifier hs-var hs-var">possible_fix_suggestion</span></a></span></span><span> </span><span id="local-6989586621681169867"><span class="annot"><span class="annottext">Maybe a
</span><a href="#local-6989586621681169867"><span class="hs-identifier hs-var">wildcard</span></a></span></span><span>
</span><span id="line-845"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe a
</span><a href="#local-6989586621681169867"><span class="hs-identifier hs-var">wildcard</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-846"></span><span>          </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-847"></span><span>            </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Possible fix: fill in the wildcard constraint yourself&quot;</span></span><span>
</span><span id="line-848"></span><span>          </span><span class="annot"><span class="annottext">Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span>
</span><span id="line-849"></span><span>            </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Possible fix: use a standalone deriving declaration instead&quot;</span></span><span>
</span><span id="line-850"></span><span>    </span><span id="local-6989586621681169874"><span class="annot"><span class="annottext">data_cons :: [DataCon]
</span><a href="#local-6989586621681169874"><span class="hs-identifier hs-var hs-var">data_cons</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [DataCon]
</span><a href="GHC.Core.TyCon.html#tyConDataCons"><span class="hs-identifier hs-var">tyConDataCons</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169881"><span class="hs-identifier hs-var">rep_tc</span></a></span><span>
</span><span id="line-851"></span><span>    </span><span id="local-6989586621681169869"><span class="annot"><span class="annottext">con_whys :: [SDoc]
</span><a href="#local-6989586621681169869"><span class="hs-identifier hs-var hs-var">con_whys</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Validity] -&gt; [SDoc]
</span><a href="GHC.Utils.Error.html#getInvalids"><span class="hs-identifier hs-var">getInvalids</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(DataCon -&gt; Validity) -&gt; [DataCon] -&gt; [Validity]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; Validity
</span><a href="#local-6989586621681169865"><span class="hs-identifier hs-var">check_con</span></a></span><span> </span><span class="annot"><span class="annottext">[DataCon]
</span><a href="#local-6989586621681169874"><span class="hs-identifier hs-var">data_cons</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-852"></span><span>
</span><span id="line-853"></span><span>    </span><span class="annot"><a href="#local-6989586621681169865"><span class="hs-identifier hs-type">check_con</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#Validity"><span class="hs-identifier hs-type">Validity</span></a></span><span>
</span><span id="line-854"></span><span>    </span><span id="local-6989586621681169865"><span class="annot"><span class="annottext">check_con :: DataCon -&gt; Validity
</span><a href="#local-6989586621681169865"><span class="hs-identifier hs-var hs-var">check_con</span></a></span></span><span> </span><span id="local-6989586621681169864"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681169864"><span class="hs-identifier hs-var">con</span></a></span></span><span>
</span><span id="line-855"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[EqSpec] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[EqSpec]
</span><a href="#local-6989586621681169863"><span class="hs-identifier hs-var">eq_spec</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- 2.</span><span>
</span><span id="line-856"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Validity
</span><a href="#local-6989586621681169862"><span class="hs-identifier hs-var">bad</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;is a GADT&quot;</span></span><span>
</span><span id="line-857"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TyVar] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681169861"><span class="hs-identifier hs-var">ex_tvs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- 3.</span><span>
</span><span id="line-858"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Validity
</span><a href="#local-6989586621681169862"><span class="hs-identifier hs-var">bad</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;has existential type variables in its type&quot;</span></span><span>
</span><span id="line-859"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Type] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681169860"><span class="hs-identifier hs-var">theta</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- 4.</span><span>
</span><span id="line-860"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Validity
</span><a href="#local-6989586621681169862"><span class="hs-identifier hs-var">bad</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;has constraints in its type&quot;</span></span><span>
</span><span id="line-861"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681169884"><span class="hs-identifier hs-var">permissive</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Bool) -&gt; [Type] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="GHC.Core.Type.html#isTauTy"><span class="hs-identifier hs-var">isTauTy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Scaled Type -&gt; Type) -&gt; [Scaled Type] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Scaled Type -&gt; Type
forall a. Scaled a -&gt; a
</span><a href="GHC.Core.TyCo.Rep.html#scaledThing"><span class="hs-identifier hs-var">scaledThing</span></a></span><span> </span><span class="annot"><span class="annottext">([Scaled Type] -&gt; [Type]) -&gt; [Scaled Type] -&gt; [Type]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; [Scaled Type]
</span><a href="GHC.Core.DataCon.html#dataConOrigArgTys"><span class="hs-identifier hs-var">dataConOrigArgTys</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681169864"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="hs-comment">-- 5.</span><span>
</span><span id="line-862"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; Validity
</span><a href="#local-6989586621681169862"><span class="hs-identifier hs-var">bad</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;has a higher-rank type&quot;</span></span><span>
</span><span id="line-863"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-864"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span>
</span><span id="line-865"></span><span>      </span><span class="hs-keyword">where</span><span>
</span><span id="line-866"></span><span>        </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[TyVar]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681169861"><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681169861"><span class="hs-identifier hs-var">ex_tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681169863"><span class="annot"><span class="annottext">[EqSpec]
</span><a href="#local-6989586621681169863"><span class="hs-identifier hs-var">eq_spec</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621681169860"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681169860"><span class="hs-identifier hs-var">theta</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[Scaled Type]
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">DataCon
-&gt; ([TyVar], [TyVar], [EqSpec], [Type], [Scaled Type], Type)
</span><a href="GHC.Core.DataCon.html#dataConFullSig"><span class="hs-identifier hs-var">dataConFullSig</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681169864"><span class="hs-identifier hs-var">con</span></a></span><span>
</span><span id="line-867"></span><span>        </span><span id="local-6989586621681169862"><span class="annot"><span class="annottext">bad :: String -&gt; Validity
</span><a href="#local-6989586621681169862"><span class="hs-identifier hs-var hs-var">bad</span></a></span></span><span> </span><span id="local-6989586621681169854"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681169854"><span class="hs-identifier hs-var">msg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Validity
</span><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-var">NotValid</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Tc.Deriv.Utils.html#badCon"><span class="hs-identifier hs-var">badCon</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681169864"><span class="hs-identifier hs-var">con</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681169854"><span class="hs-identifier hs-var">msg</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-868"></span><span>
</span><span id="line-869"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#no_cons_why"><span class="hs-identifier hs-type">no_cons_why</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCon.html#TyCon"><span class="hs-identifier hs-type">TyCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-870"></span><span id="no_cons_why"><span class="annot"><span class="annottext">no_cons_why :: TyCon -&gt; SDoc
</span><a href="GHC.Tc.Deriv.Utils.html#no_cons_why"><span class="hs-identifier hs-var hs-var">no_cons_why</span></a></span></span><span> </span><span id="local-6989586621681169852"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169852"><span class="hs-identifier hs-var">rep_tc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#pprSourceTyCon"><span class="hs-identifier hs-var">pprSourceTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169852"><span class="hs-identifier hs-var">rep_tc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-871"></span><span>                     </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;must have at least one data constructor&quot;</span></span><span>
</span><span id="line-872"></span><span>
</span><span id="line-873"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#cond_RepresentableOk"><span class="hs-identifier hs-type">cond_RepresentableOk</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#Condition"><span class="hs-identifier hs-type">Condition</span></a></span><span>
</span><span id="line-874"></span><span id="cond_RepresentableOk"><span class="annot"><span class="annottext">cond_RepresentableOk :: Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_RepresentableOk"><span class="hs-identifier hs-var hs-var">cond_RepresentableOk</span></a></span></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681169851"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169851"><span class="hs-identifier hs-var">rep_tc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Validity
</span><a href="GHC.Tc.Deriv.Generics.html#canDoGenerics"><span class="hs-identifier hs-var">canDoGenerics</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169851"><span class="hs-identifier hs-var">rep_tc</span></a></span><span>
</span><span id="line-875"></span><span>
</span><span id="line-876"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#cond_Representable1Ok"><span class="hs-identifier hs-type">cond_Representable1Ok</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#Condition"><span class="hs-identifier hs-type">Condition</span></a></span><span>
</span><span id="line-877"></span><span id="cond_Representable1Ok"><span class="annot"><span class="annottext">cond_Representable1Ok :: Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_Representable1Ok"><span class="hs-identifier hs-var hs-var">cond_Representable1Ok</span></a></span></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681169849"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169849"><span class="hs-identifier hs-var">rep_tc</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Validity
</span><a href="GHC.Tc.Deriv.Generics.html#canDoGenerics1"><span class="hs-identifier hs-var">canDoGenerics1</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169849"><span class="hs-identifier hs-var">rep_tc</span></a></span><span>
</span><span id="line-878"></span><span>
</span><span id="line-879"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#cond_enumOrProduct"><span class="hs-identifier hs-type">cond_enumOrProduct</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#Condition"><span class="hs-identifier hs-type">Condition</span></a></span><span>
</span><span id="line-880"></span><span id="cond_enumOrProduct"><span class="annot"><span class="annottext">cond_enumOrProduct :: Class -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_enumOrProduct"><span class="hs-identifier hs-var hs-var">cond_enumOrProduct</span></a></span></span><span> </span><span id="local-6989586621681169847"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169847"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_isEnumeration"><span class="hs-identifier hs-var">cond_isEnumeration</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#orCond"><span class="hs-operator hs-var">`orCond`</span></a></span><span>
</span><span id="line-881"></span><span>                         </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_isProduct"><span class="hs-identifier hs-var">cond_isProduct</span></a></span><span> </span><span class="annot"><span class="annottext">Condition -&gt; Condition -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#andCond"><span class="hs-operator hs-var">`andCond`</span></a></span><span> </span><span class="annot"><span class="annottext">Class -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_args"><span class="hs-identifier hs-var">cond_args</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169847"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-882"></span><span>
</span><span id="line-883"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#cond_args"><span class="hs-identifier hs-type">cond_args</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#Condition"><span class="hs-identifier hs-type">Condition</span></a></span><span>
</span><span id="line-884"></span><span class="hs-comment">-- ^ For some classes (eg 'Eq', 'Ord') we allow unlifted arg types</span><span>
</span><span id="line-885"></span><span class="hs-comment">-- by generating specialised code.  For others (eg 'Data') we don't.</span><span>
</span><span id="line-886"></span><span class="hs-comment">-- For even others (eg 'Lift'), unlifted types aren't even a special</span><span>
</span><span id="line-887"></span><span class="hs-comment">-- consideration!</span><span>
</span><span id="line-888"></span><span id="cond_args"><span class="annot"><span class="annottext">cond_args :: Class -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_args"><span class="hs-identifier hs-var hs-var">cond_args</span></a></span></span><span> </span><span id="local-6989586621681169845"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169845"><span class="hs-identifier hs-var">cls</span></a></span></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681169844"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169844"><span class="hs-identifier hs-var">rep_tc</span></a></span></span><span>
</span><span id="line-889"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681169843"><span class="hs-identifier hs-var">bad_args</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-890"></span><span>      </span><span class="hs-special">[</span><span class="hs-special">]</span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span>
</span><span id="line-891"></span><span>      </span><span class="hs-special">(</span><span id="local-6989586621681169842"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681169842"><span class="hs-identifier hs-var">ty</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">[Type]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Validity
</span><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-var">NotValid</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">SDoc -&gt; Int -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#hang"><span class="hs-identifier hs-var">hang</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Don't know how to derive&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Class -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169845"><span class="hs-identifier hs-var">cls</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-892"></span><span>                             </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;for type&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681169842"><span class="hs-identifier hs-var">ty</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-893"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-894"></span><span>    </span><span id="local-6989586621681169843"><span class="annot"><span class="annottext">bad_args :: [Type]
</span><a href="#local-6989586621681169843"><span class="hs-identifier hs-var hs-var">bad_args</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681169841"><span class="hs-identifier hs-var">arg_ty</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681169840"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681169840"><span class="hs-identifier hs-var">con</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [DataCon]
</span><a href="GHC.Core.TyCon.html#tyConDataCons"><span class="hs-identifier hs-var">tyConDataCons</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169844"><span class="hs-identifier hs-var">rep_tc</span></a></span><span>
</span><span id="line-895"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Scaled"><span class="hs-identifier hs-type">Scaled</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681169841"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681169841"><span class="hs-identifier hs-var">arg_ty</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; [Scaled Type]
</span><a href="GHC.Core.DataCon.html#dataConOrigArgTys"><span class="hs-identifier hs-var">dataConOrigArgTys</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681169840"><span class="hs-identifier hs-var">con</span></a></span><span>
</span><span id="line-896"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">HasDebugCallStack =&gt; Type -&gt; Maybe Bool
Type -&gt; Maybe Bool
</span><a href="GHC.Core.Type.html#isLiftedType_maybe"><span class="hs-identifier hs-var">isLiftedType_maybe</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681169841"><span class="hs-identifier hs-var">arg_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe Bool -&gt; Maybe Bool -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">/=</span></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Maybe Bool
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>
</span><span id="line-897"></span><span>                        </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="#local-6989586621681169836"><span class="hs-identifier hs-var">ok_ty</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681169841"><span class="hs-identifier hs-var">arg_ty</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-898"></span><span>
</span><span id="line-899"></span><span>    </span><span id="local-6989586621681169835"><span class="annot"><span class="annottext">cls_key :: Unique
</span><a href="#local-6989586621681169835"><span class="hs-identifier hs-var hs-var">cls_key</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Class -&gt; Unique
</span><a href="GHC.Core.Class.html#classKey"><span class="hs-identifier hs-var hs-var">classKey</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169845"><span class="hs-identifier hs-var">cls</span></a></span><span>
</span><span id="line-900"></span><span>    </span><span id="local-6989586621681169836"><span class="annot"><span class="annottext">ok_ty :: Type -&gt; Bool
</span><a href="#local-6989586621681169836"><span class="hs-identifier hs-var hs-var">ok_ty</span></a></span></span><span> </span><span id="local-6989586621681169833"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681169833"><span class="hs-identifier hs-var">arg_ty</span></a></span></span><span>
</span><span id="line-901"></span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681169835"><span class="hs-identifier hs-var">cls_key</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Unique -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#eqClassKey"><span class="hs-identifier hs-var">eqClassKey</span></a></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
-&gt; [(Type, (RdrName, RdrName, RdrName, RdrName, RdrName))] -&gt; Bool
forall a. Type -&gt; [(Type, a)] -&gt; Bool
</span><a href="#local-6989586621681169832"><span class="hs-identifier hs-var">check_in</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681169833"><span class="hs-identifier hs-var">arg_ty</span></a></span><span> </span><span class="annot"><span class="annottext">[(Type, (RdrName, RdrName, RdrName, RdrName, RdrName))]
</span><a href="GHC.Tc.Deriv.Generate.html#ordOpTbl"><span class="hs-identifier hs-var">ordOpTbl</span></a></span><span>
</span><span id="line-902"></span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681169835"><span class="hs-identifier hs-var">cls_key</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Unique -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#ordClassKey"><span class="hs-identifier hs-var">ordClassKey</span></a></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type
-&gt; [(Type, (RdrName, RdrName, RdrName, RdrName, RdrName))] -&gt; Bool
forall a. Type -&gt; [(Type, a)] -&gt; Bool
</span><a href="#local-6989586621681169832"><span class="hs-identifier hs-var">check_in</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681169833"><span class="hs-identifier hs-var">arg_ty</span></a></span><span> </span><span class="annot"><span class="annottext">[(Type, (RdrName, RdrName, RdrName, RdrName, RdrName))]
</span><a href="GHC.Tc.Deriv.Generate.html#ordOpTbl"><span class="hs-identifier hs-var">ordOpTbl</span></a></span><span>
</span><span id="line-903"></span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681169835"><span class="hs-identifier hs-var">cls_key</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Unique -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#showClassKey"><span class="hs-identifier hs-var">showClassKey</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Type -&gt; [(Type, LHsExpr GhcPs -&gt; LHsExpr GhcPs)] -&gt; Bool
forall a. Type -&gt; [(Type, a)] -&gt; Bool
</span><a href="#local-6989586621681169832"><span class="hs-identifier hs-var">check_in</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681169833"><span class="hs-identifier hs-var">arg_ty</span></a></span><span> </span><span class="annot"><span class="annottext">[(Type, LHsExpr GhcPs -&gt; LHsExpr GhcPs)]
</span><a href="GHC.Tc.Deriv.Generate.html#boxConTbl"><span class="hs-identifier hs-var">boxConTbl</span></a></span><span>
</span><span id="line-904"></span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="#local-6989586621681169835"><span class="hs-identifier hs-var">cls_key</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; Unique -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.TH.html#liftClassKey"><span class="hs-identifier hs-var">liftClassKey</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">True</span></span><span>     </span><span class="hs-comment">-- Lift is levity-polymorphic</span><span>
</span><span id="line-905"></span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>               </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
</span><span class="hs-identifier hs-var">False</span></span><span>    </span><span class="hs-comment">-- Read, Ix etc</span><span>
</span><span id="line-906"></span><span>
</span><span id="line-907"></span><span>    </span><span id="local-6989586621681170395"><span class="annot"><a href="#local-6989586621681169832"><span class="hs-identifier hs-type">check_in</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#Type"><span class="hs-identifier hs-type">Type</span></a></span><span class="hs-special">,</span><span class="annot"><a href="#local-6989586621681170395"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span></span><span>
</span><span id="line-908"></span><span>    </span><span id="local-6989586621681169832"><span class="annot"><span class="annottext">check_in :: forall a. Type -&gt; [(Type, a)] -&gt; Bool
</span><a href="#local-6989586621681169832"><span class="hs-identifier hs-var hs-var">check_in</span></a></span></span><span> </span><span id="local-6989586621681169828"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681169828"><span class="hs-identifier hs-var">arg_ty</span></a></span></span><span> </span><span id="local-6989586621681169827"><span class="annot"><span class="annottext">[(Type, a)]
</span><a href="#local-6989586621681169827"><span class="hs-identifier hs-var">tbl</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">((Type, a) -&gt; Bool) -&gt; [(Type, a)] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#any"><span class="hs-identifier hs-var">any</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; Type -&gt; Bool
</span><a href="GHC.Core.Type.html#eqType"><span class="hs-identifier hs-var">eqType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681169828"><span class="hs-identifier hs-var">arg_ty</span></a></span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Bool) -&gt; ((Type, a) -&gt; Type) -&gt; (Type, a) -&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(Type, a) -&gt; Type
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[(Type, a)]
</span><a href="#local-6989586621681169827"><span class="hs-identifier hs-var">tbl</span></a></span><span>
</span><span id="line-909"></span><span>
</span><span id="line-910"></span><span>
</span><span id="line-911"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#cond_isEnumeration"><span class="hs-identifier hs-type">cond_isEnumeration</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#Condition"><span class="hs-identifier hs-type">Condition</span></a></span><span>
</span><span id="line-912"></span><span id="cond_isEnumeration"><span class="annot"><span class="annottext">cond_isEnumeration :: Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_isEnumeration"><span class="hs-identifier hs-var hs-var">cond_isEnumeration</span></a></span></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681169824"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169824"><span class="hs-identifier hs-var">rep_tc</span></a></span></span><span>
</span><span id="line-913"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isEnumerationTyCon"><span class="hs-identifier hs-var">isEnumerationTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169824"><span class="hs-identifier hs-var">rep_tc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span>
</span><span id="line-914"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>                 </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Validity
</span><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-var">NotValid</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681169822"><span class="hs-identifier hs-var">why</span></a></span><span>
</span><span id="line-915"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-916"></span><span>    </span><span id="local-6989586621681169822"><span class="annot"><span class="annottext">why :: SDoc
</span><a href="#local-6989586621681169822"><span class="hs-identifier hs-var hs-var">why</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[SDoc] -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#sep"><span class="hs-identifier hs-var">sep</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#pprSourceTyCon"><span class="hs-identifier hs-var">pprSourceTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169824"><span class="hs-identifier hs-var">rep_tc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-917"></span><span>                  </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;must be an enumeration type&quot;</span></span><span>
</span><span id="line-918"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;(an enumeration consists of one or more nullary, non-GADT constructors)&quot;</span></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-919"></span><span>                  </span><span class="hs-comment">-- See Note [Enumeration types] in GHC.Core.TyCon</span><span>
</span><span id="line-920"></span><span>
</span><span id="line-921"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#cond_isProduct"><span class="hs-identifier hs-type">cond_isProduct</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#Condition"><span class="hs-identifier hs-type">Condition</span></a></span><span>
</span><span id="line-922"></span><span id="cond_isProduct"><span class="annot"><span class="annottext">cond_isProduct :: Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_isProduct"><span class="hs-identifier hs-var hs-var">cond_isProduct</span></a></span></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681169820"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169820"><span class="hs-identifier hs-var">rep_tc</span></a></span></span><span>
</span><span id="line-923"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; Bool
</span><a href="GHC.Core.TyCon.html#isProductTyCon"><span class="hs-identifier hs-var">isProductTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169820"><span class="hs-identifier hs-var">rep_tc</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span>
</span><span id="line-924"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Validity
</span><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-var">NotValid</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681169818"><span class="hs-identifier hs-var">why</span></a></span><span>
</span><span id="line-925"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-926"></span><span>    </span><span id="local-6989586621681169818"><span class="annot"><span class="annottext">why :: SDoc
</span><a href="#local-6989586621681169818"><span class="hs-identifier hs-var hs-var">why</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#pprSourceTyCon"><span class="hs-identifier hs-var">pprSourceTyCon</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169820"><span class="hs-identifier hs-var">rep_tc</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span>
</span><span id="line-927"></span><span>          </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;must have precisely one constructor&quot;</span></span><span>
</span><span id="line-928"></span><span>
</span><span id="line-929"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#cond_functorOK"><span class="hs-identifier hs-type">cond_functorOK</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#Condition"><span class="hs-identifier hs-type">Condition</span></a></span><span>
</span><span id="line-930"></span><span class="hs-comment">-- OK for Functor/Foldable/Traversable class</span><span>
</span><span id="line-931"></span><span class="hs-comment">-- Currently: (a) at least one argument</span><span>
</span><span id="line-932"></span><span class="hs-comment">--            (b) don't use argument contravariantly</span><span>
</span><span id="line-933"></span><span class="hs-comment">--            (c) don't use argument in the wrong place, e.g. data T a = T (X a a)</span><span>
</span><span id="line-934"></span><span class="hs-comment">--            (d) optionally: don't use function types</span><span>
</span><span id="line-935"></span><span class="hs-comment">--            (e) no &quot;stupid context&quot; on data type</span><span>
</span><span id="line-936"></span><span id="cond_functorOK"><span class="annot"><span class="annottext">cond_functorOK :: Bool -&gt; Bool -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#cond_functorOK"><span class="hs-identifier hs-var hs-var">cond_functorOK</span></a></span></span><span> </span><span id="local-6989586621681169817"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681169817"><span class="hs-identifier hs-var">allowFunctions</span></a></span></span><span> </span><span id="local-6989586621681169816"><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681169816"><span class="hs-identifier hs-var">allowExQuantifiedLastTyVar</span></a></span></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681169815"><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169815"><span class="hs-identifier hs-var">rep_tc</span></a></span></span><span>
</span><span id="line-937"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681169814"><span class="hs-identifier hs-var">tc_tvs</span></a></span><span>
</span><span id="line-938"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Validity
</span><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-var">NotValid</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Data type&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169815"><span class="hs-identifier hs-var">rep_tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-939"></span><span>              </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;must have some type parameters&quot;</span></span><span class="hs-special">)</span><span>
</span><span id="line-940"></span><span>
</span><span id="line-941"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Type] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681169813"><span class="hs-identifier hs-var">bad_stupid_theta</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-942"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Validity
</span><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-var">NotValid</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Data type&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169815"><span class="hs-identifier hs-var">rep_tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-943"></span><span>              </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;must not have a class context:&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; SDoc
</span><a href="GHC.Core.TyCo.Ppr.html#pprTheta"><span class="hs-identifier hs-var">pprTheta</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681169813"><span class="hs-identifier hs-var">bad_stupid_theta</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-944"></span><span>
</span><span id="line-945"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-946"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Validity] -&gt; Validity
</span><a href="GHC.Utils.Error.html#allValid"><span class="hs-identifier hs-var">allValid</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(DataCon -&gt; Validity) -&gt; [DataCon] -&gt; [Validity]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; Validity
</span><a href="#local-6989586621681169810"><span class="hs-identifier hs-var">check_con</span></a></span><span> </span><span class="annot"><span class="annottext">[DataCon]
</span><a href="#local-6989586621681169809"><span class="hs-identifier hs-var">data_cons</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-947"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-948"></span><span>    </span><span id="local-6989586621681169814"><span class="annot"><span class="annottext">tc_tvs :: [TyVar]
</span><a href="#local-6989586621681169814"><span class="hs-identifier hs-var hs-var">tc_tvs</span></a></span></span><span>            </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [TyVar]
</span><a href="GHC.Core.TyCon.html#tyConTyVars"><span class="hs-identifier hs-var hs-var">tyConTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169815"><span class="hs-identifier hs-var">rep_tc</span></a></span><span>
</span><span id="line-949"></span><span>    </span><span id="local-6989586621681169807"><span class="annot"><span class="annottext">last_tv :: TyVar
</span><a href="#local-6989586621681169807"><span class="hs-identifier hs-var hs-var">last_tv</span></a></span></span><span>           </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[TyVar] -&gt; TyVar
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#last"><span class="hs-identifier hs-var">last</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681169814"><span class="hs-identifier hs-var">tc_tvs</span></a></span><span>
</span><span id="line-950"></span><span>    </span><span id="local-6989586621681169813"><span class="annot"><span class="annottext">bad_stupid_theta :: [Type]
</span><a href="#local-6989586621681169813"><span class="hs-identifier hs-var hs-var">bad_stupid_theta</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Type -&gt; Bool) -&gt; [Type] -&gt; [Type]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; Bool
</span><a href="#local-6989586621681169805"><span class="hs-identifier hs-var">is_bad</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyCon -&gt; [Type]
</span><a href="GHC.Core.TyCon.html#tyConStupidTheta"><span class="hs-identifier hs-var">tyConStupidTheta</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169815"><span class="hs-identifier hs-var">rep_tc</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-951"></span><span>    </span><span id="local-6989586621681169805"><span class="annot"><span class="annottext">is_bad :: Type -&gt; Bool
</span><a href="#local-6989586621681169805"><span class="hs-identifier hs-var hs-var">is_bad</span></a></span></span><span> </span><span id="local-6989586621681169803"><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681169803"><span class="hs-identifier hs-var">pred</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681169807"><span class="hs-identifier hs-var">last_tv</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">Type -&gt; VarSet
</span><a href="GHC.Tc.Utils.TcType.html#exactTyCoVarsOfType"><span class="hs-identifier hs-var">exactTyCoVarsOfType</span></a></span><span> </span><span class="annot"><span class="annottext">Type
</span><a href="#local-6989586621681169803"><span class="hs-identifier hs-var">pred</span></a></span><span>
</span><span id="line-952"></span><span>      </span><span class="hs-comment">-- See Note [Check that the type variable is truly universal]</span><span>
</span><span id="line-953"></span><span>
</span><span id="line-954"></span><span>    </span><span id="local-6989586621681169809"><span class="annot"><span class="annottext">data_cons :: [DataCon]
</span><a href="#local-6989586621681169809"><span class="hs-identifier hs-var hs-var">data_cons</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TyCon -&gt; [DataCon]
</span><a href="GHC.Core.TyCon.html#tyConDataCons"><span class="hs-identifier hs-var">tyConDataCons</span></a></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><a href="#local-6989586621681169815"><span class="hs-identifier hs-var">rep_tc</span></a></span><span>
</span><span id="line-955"></span><span>    </span><span id="local-6989586621681169810"><span class="annot"><span class="annottext">check_con :: DataCon -&gt; Validity
</span><a href="#local-6989586621681169810"><span class="hs-identifier hs-var hs-var">check_con</span></a></span></span><span> </span><span id="local-6989586621681169800"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681169800"><span class="hs-identifier hs-var">con</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[Validity] -&gt; Validity
</span><a href="GHC.Utils.Error.html#allValid"><span class="hs-identifier hs-var">allValid</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; Validity
</span><a href="#local-6989586621681169799"><span class="hs-identifier hs-var">check_universal</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681169800"><span class="hs-identifier hs-var">con</span></a></span><span> </span><span class="annot"><span class="annottext">Validity -&gt; [Validity] -&gt; [Validity]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">FFoldType Validity -&gt; DataCon -&gt; [Validity]
forall a. FFoldType a -&gt; DataCon -&gt; [a]
</span><a href="GHC.Tc.Deriv.Functor.html#foldDataConArgs"><span class="hs-identifier hs-var">foldDataConArgs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; FFoldType Validity
</span><a href="#local-6989586621681169797"><span class="hs-identifier hs-var">ft_check</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681169800"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681169800"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-956"></span><span>
</span><span id="line-957"></span><span>    </span><span class="annot"><a href="#local-6989586621681169799"><span class="hs-identifier hs-type">check_universal</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#Validity"><span class="hs-identifier hs-type">Validity</span></a></span><span>
</span><span id="line-958"></span><span>    </span><span id="local-6989586621681169799"><span class="annot"><span class="annottext">check_universal :: DataCon -&gt; Validity
</span><a href="#local-6989586621681169799"><span class="hs-identifier hs-var hs-var">check_universal</span></a></span></span><span> </span><span id="local-6989586621681169796"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681169796"><span class="hs-identifier hs-var">con</span></a></span></span><span>
</span><span id="line-959"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681169816"><span class="hs-identifier hs-var">allowExQuantifiedLastTyVar</span></a></span><span>
</span><span id="line-960"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span> </span><span class="hs-comment">-- See Note [DeriveFoldable with ExistentialQuantification]</span><span>
</span><span id="line-961"></span><span>                </span><span class="hs-comment">-- in GHC.Tc.Deriv.Functor</span><span>
</span><span id="line-962"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621681169795"><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681169795"><span class="hs-identifier hs-var">tv</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Type -&gt; Maybe TyVar
</span><a href="GHC.Core.Type.html#getTyVar_maybe"><span class="hs-identifier hs-var">getTyVar_maybe</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[Type] -&gt; Type
forall a. [a] -&gt; a
</span><a href="../../base/src/GHC.List.html#last"><span class="hs-identifier hs-var">last</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Type -&gt; [Type]
</span><a href="GHC.Core.Type.html#tyConAppArgs"><span class="hs-identifier hs-var">tyConAppArgs</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; Type
</span><a href="GHC.Core.DataCon.html#dataConOrigResTy"><span class="hs-identifier hs-var">dataConOrigResTy</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681169796"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-963"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681169795"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; [TyVar] -&gt; Bool
forall (t :: * -&gt; *) a. (Foldable t, Eq a) =&gt; a -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#elem"><span class="hs-operator hs-var">`elem`</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon -&gt; [TyVar]
</span><a href="GHC.Core.DataCon.html#dataConUnivTyVars"><span class="hs-identifier hs-var">dataConUnivTyVars</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681169796"><span class="hs-identifier hs-var">con</span></a></span><span>
</span><span id="line-964"></span><span>      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TyVar
</span><a href="#local-6989586621681169795"><span class="hs-identifier hs-var">tv</span></a></span><span> </span><span class="annot"><span class="annottext">TyVar -&gt; VarSet -&gt; Bool
</span><a href="GHC.Types.Var.Set.html#elemVarSet"><span class="hs-operator hs-var">`elemVarSet`</span></a></span><span> </span><span class="annot"><span class="annottext">[Type] -&gt; VarSet
</span><a href="GHC.Tc.Utils.TcType.html#exactTyCoVarsOfTypes"><span class="hs-identifier hs-var">exactTyCoVarsOfTypes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; [Type]
</span><a href="GHC.Core.DataCon.html#dataConTheta"><span class="hs-identifier hs-var">dataConTheta</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681169796"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-965"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span>   </span><span class="hs-comment">-- See Note [Check that the type variable is truly universal]</span><span>
</span><span id="line-966"></span><span>      </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>
</span><span id="line-967"></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Validity
</span><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-var">NotValid</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Tc.Deriv.Utils.html#badCon"><span class="hs-identifier hs-var">badCon</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681169796"><span class="hs-identifier hs-var">con</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681169787"><span class="hs-identifier hs-var">existential</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-968"></span><span>
</span><span id="line-969"></span><span>    </span><span class="annot"><a href="#local-6989586621681169797"><span class="hs-identifier hs-type">ft_check</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Functor.html#FFoldType"><span class="hs-identifier hs-type">FFoldType</span></a></span><span> </span><span class="annot"><a href="GHC.Utils.Error.html#Validity"><span class="hs-identifier hs-type">Validity</span></a></span><span>
</span><span id="line-970"></span><span>    </span><span id="local-6989586621681169797"><span class="annot"><span class="annottext">ft_check :: DataCon -&gt; FFoldType Validity
</span><a href="#local-6989586621681169797"><span class="hs-identifier hs-var hs-var">ft_check</span></a></span></span><span> </span><span id="local-6989586621681169786"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681169786"><span class="hs-identifier hs-var">con</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">FT :: forall a.
a
-&gt; a
-&gt; a
-&gt; (a -&gt; a -&gt; a)
-&gt; (TyCon -&gt; [a] -&gt; a)
-&gt; (Type -&gt; Type -&gt; a -&gt; a)
-&gt; a
-&gt; (TyVar -&gt; a -&gt; a)
-&gt; FFoldType a
</span><a href="GHC.Tc.Deriv.Functor.html#FT"><span class="hs-identifier hs-type">FT</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ft_triv :: Validity
</span><a href="GHC.Tc.Deriv.Functor.html#ft_triv"><span class="hs-identifier hs-var">ft_triv</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_var :: Validity
</span><a href="GHC.Tc.Deriv.Functor.html#ft_var"><span class="hs-identifier hs-var">ft_var</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span>
</span><span id="line-971"></span><span>                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_co_var :: Validity
</span><a href="GHC.Tc.Deriv.Functor.html#ft_co_var"><span class="hs-identifier hs-var">ft_co_var</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Validity
</span><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-var">NotValid</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Tc.Deriv.Utils.html#badCon"><span class="hs-identifier hs-var">badCon</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681169786"><span class="hs-identifier hs-var">con</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681169781"><span class="hs-identifier hs-var">covariant</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-972"></span><span>                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_fun :: Validity -&gt; Validity -&gt; Validity
</span><a href="GHC.Tc.Deriv.Functor.html#ft_fun"><span class="hs-identifier hs-var">ft_fun</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-glyph">\</span><span id="local-6989586621681169779"><span class="annot"><span class="annottext">Validity
</span><a href="#local-6989586621681169779"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span id="local-6989586621681169778"><span class="annot"><span class="annottext">Validity
</span><a href="#local-6989586621681169778"><span class="hs-identifier hs-var">y</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621681169817"><span class="hs-identifier hs-var">allowFunctions</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="#local-6989586621681169779"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="annot"><span class="annottext">Validity -&gt; Validity -&gt; Validity
</span><a href="GHC.Utils.Error.html#andValid"><span class="hs-operator hs-var">`andValid`</span></a></span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="#local-6989586621681169778"><span class="hs-identifier hs-var">y</span></a></span><span>
</span><span id="line-973"></span><span>                                                           </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Validity
</span><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-var">NotValid</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Tc.Deriv.Utils.html#badCon"><span class="hs-identifier hs-var">badCon</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681169786"><span class="hs-identifier hs-var">con</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681169777"><span class="hs-identifier hs-var">functions</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-974"></span><span>                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_tup :: TyCon -&gt; [Validity] -&gt; Validity
</span><a href="GHC.Tc.Deriv.Functor.html#ft_tup"><span class="hs-identifier hs-var">ft_tup</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">TyCon
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681169775"><span class="annot"><span class="annottext">[Validity]
</span><a href="#local-6989586621681169775"><span class="hs-identifier hs-var">xs</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[Validity] -&gt; Validity
</span><a href="GHC.Utils.Error.html#allValid"><span class="hs-identifier hs-var">allValid</span></a></span><span> </span><span class="annot"><span class="annottext">[Validity]
</span><a href="#local-6989586621681169775"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-975"></span><span>                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_ty_app :: Type -&gt; Type -&gt; Validity -&gt; Validity
</span><a href="GHC.Tc.Deriv.Functor.html#ft_ty_app"><span class="hs-identifier hs-var">ft_ty_app</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">Type
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681169773"><span class="annot"><span class="annottext">Validity
</span><a href="#local-6989586621681169773"><span class="hs-identifier hs-var">x</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="#local-6989586621681169773"><span class="hs-identifier hs-var">x</span></a></span><span>
</span><span id="line-976"></span><span>                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_bad_app :: Validity
</span><a href="GHC.Tc.Deriv.Functor.html#ft_bad_app"><span class="hs-identifier hs-var">ft_bad_app</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Validity
</span><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-var">NotValid</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Tc.Deriv.Utils.html#badCon"><span class="hs-identifier hs-var">badCon</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681169786"><span class="hs-identifier hs-var">con</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681169771"><span class="hs-identifier hs-var">wrong_arg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-977"></span><span>                      </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ft_forall :: TyVar -&gt; Validity -&gt; Validity
</span><a href="GHC.Tc.Deriv.Functor.html#ft_forall"><span class="hs-identifier hs-var">ft_forall</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">TyVar
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621681169769"><span class="annot"><span class="annottext">Validity
</span><a href="#local-6989586621681169769"><span class="hs-identifier hs-var">x</span></a></span></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="#local-6989586621681169769"><span class="hs-identifier hs-var">x</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-978"></span><span>
</span><span id="line-979"></span><span>    </span><span id="local-6989586621681169787"><span class="annot"><span class="annottext">existential :: SDoc
</span><a href="#local-6989586621681169787"><span class="hs-identifier hs-var hs-var">existential</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;must be truly polymorphic in the last argument of the data type&quot;</span></span><span>
</span><span id="line-980"></span><span>    </span><span id="local-6989586621681169781"><span class="annot"><span class="annottext">covariant :: SDoc
</span><a href="#local-6989586621681169781"><span class="hs-identifier hs-var hs-var">covariant</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;must not use the type variable in a function argument&quot;</span></span><span>
</span><span id="line-981"></span><span>    </span><span id="local-6989586621681169777"><span class="annot"><span class="annottext">functions :: SDoc
</span><a href="#local-6989586621681169777"><span class="hs-identifier hs-var hs-var">functions</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;must not contain function types&quot;</span></span><span>
</span><span id="line-982"></span><span>    </span><span id="local-6989586621681169771"><span class="annot"><span class="annottext">wrong_arg :: SDoc
</span><a href="#local-6989586621681169771"><span class="hs-identifier hs-var hs-var">wrong_arg</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;must use the type variable only as the last argument of a data type&quot;</span></span><span>
</span><span id="line-983"></span><span>
</span><span id="line-984"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#checkFlag"><span class="hs-identifier hs-type">checkFlag</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../ghc-boot-th/src/GHC.LanguageExtensions.Type.html#Extension"><span class="hs-identifier hs-type">LangExt.Extension</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#Condition"><span class="hs-identifier hs-type">Condition</span></a></span><span>
</span><span id="line-985"></span><span id="checkFlag"><span class="annot"><span class="annottext">checkFlag :: Extension -&gt; Condition
</span><a href="GHC.Tc.Deriv.Utils.html#checkFlag"><span class="hs-identifier hs-var hs-var">checkFlag</span></a></span></span><span> </span><span id="local-6989586621681169768"><span class="annot"><span class="annottext">Extension
</span><a href="#local-6989586621681169768"><span class="hs-identifier hs-var">flag</span></a></span></span><span> </span><span id="local-6989586621681169767"><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681169767"><span class="hs-identifier hs-var">dflags</span></a></span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">TyCon
</span><span class="hs-identifier">_</span></span><span>
</span><span id="line-986"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Extension -&gt; DynFlags -&gt; Bool
</span><a href="GHC.Driver.Session.html#xopt"><span class="hs-identifier hs-var">xopt</span></a></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="#local-6989586621681169768"><span class="hs-identifier hs-var">flag</span></a></span><span> </span><span class="annot"><span class="annottext">DynFlags
</span><a href="#local-6989586621681169767"><span class="hs-identifier hs-var">dflags</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Validity
</span><a href="GHC.Utils.Error.html#IsValid"><span class="hs-identifier hs-var">IsValid</span></a></span><span>
</span><span id="line-987"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span>        </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; Validity
</span><a href="GHC.Utils.Error.html#NotValid"><span class="hs-identifier hs-var">NotValid</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681169766"><span class="hs-identifier hs-var">why</span></a></span><span>
</span><span id="line-988"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-989"></span><span>    </span><span id="local-6989586621681169766"><span class="annot"><span class="annottext">why :: SDoc
</span><a href="#local-6989586621681169766"><span class="hs-identifier hs-var hs-var">why</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;You need &quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%3E"><span class="hs-operator hs-var">&lt;&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681169764"><span class="hs-identifier hs-var">flag_str</span></a></span><span>
</span><span id="line-990"></span><span>          </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;to derive an instance for this class&quot;</span></span><span>
</span><span id="line-991"></span><span>    </span><span id="local-6989586621681169764"><span class="annot"><span class="annottext">flag_str :: String
</span><a href="#local-6989586621681169764"><span class="hs-identifier hs-var hs-var">flag_str</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">FlagSpec Extension -&gt; String
forall flag. FlagSpec flag -&gt; String
</span><a href="GHC.Driver.Session.html#flagSpecName"><span class="hs-identifier hs-var hs-var">flagSpecName</span></a></span><span> </span><span class="annot"><span class="annottext">FlagSpec Extension
</span><a href="#local-6989586621681169762"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621681169762"><span class="annot"><span class="annottext">FlagSpec Extension
</span><a href="#local-6989586621681169762"><span class="hs-identifier hs-var">f</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[FlagSpec Extension]
</span><a href="GHC.Driver.Session.html#xFlags"><span class="hs-identifier hs-var">xFlags</span></a></span><span> </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">FlagSpec Extension -&gt; Extension
forall flag. FlagSpec flag -&gt; flag
</span><a href="GHC.Driver.Session.html#flagSpecFlag"><span class="hs-identifier hs-var hs-var">flagSpecFlag</span></a></span><span> </span><span class="annot"><span class="annottext">FlagSpec Extension
</span><a href="#local-6989586621681169762"><span class="hs-identifier hs-var">f</span></a></span><span> </span><span class="annot"><span class="annottext">Extension -&gt; Extension -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Extension
</span><a href="#local-6989586621681169768"><span class="hs-identifier hs-var">flag</span></a></span><span> </span><span class="hs-special">]</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-992"></span><span>                 </span><span class="hs-special">[</span><span id="local-6989586621681169759"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681169759"><span class="hs-identifier hs-var">s</span></a></span></span><span class="hs-special">]</span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621681169759"><span class="hs-identifier hs-var">s</span></a></span><span>
</span><span id="line-993"></span><span>                 </span><span id="local-6989586621681169758"><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681169758"><span class="hs-identifier hs-var">other</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc -&gt; String
forall a. HasCallStack =&gt; String -&gt; SDoc -&gt; a
</span><a href="GHC.Utils.Outputable.html#pprPanic"><span class="hs-identifier hs-var">pprPanic</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;checkFlag&quot;</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[String] -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">[String]
</span><a href="#local-6989586621681169758"><span class="hs-identifier hs-var">other</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-994"></span><span>
</span><span id="line-995"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#std_class_via_coercible"><span class="hs-identifier hs-type">std_class_via_coercible</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-996"></span><span class="hs-comment">-- These standard classes can be derived for a newtype</span><span>
</span><span id="line-997"></span><span class="hs-comment">-- using the coercible trick *even if no -XGeneralizedNewtypeDeriving</span><span>
</span><span id="line-998"></span><span class="hs-comment">-- because giving so gives the same results as generating the boilerplate</span><span>
</span><span id="line-999"></span><span id="std_class_via_coercible"><span class="annot"><span class="annottext">std_class_via_coercible :: Class -&gt; Bool
</span><a href="GHC.Tc.Deriv.Utils.html#std_class_via_coercible"><span class="hs-identifier hs-var hs-var">std_class_via_coercible</span></a></span></span><span> </span><span id="local-6989586621681169756"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169756"><span class="hs-identifier hs-var">clas</span></a></span></span><span>
</span><span id="line-1000"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Class -&gt; Unique
</span><a href="GHC.Core.Class.html#classKey"><span class="hs-identifier hs-var hs-var">classKey</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169756"><span class="hs-identifier hs-var">clas</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; [Unique] -&gt; Bool
forall (t :: * -&gt; *) a. (Foldable t, Eq a) =&gt; a -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#elem"><span class="hs-operator hs-var">`elem`</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#eqClassKey"><span class="hs-identifier hs-var">eqClassKey</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#ordClassKey"><span class="hs-identifier hs-var">ordClassKey</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#ixClassKey"><span class="hs-identifier hs-var">ixClassKey</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#boundedClassKey"><span class="hs-identifier hs-var">boundedClassKey</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-1001"></span><span>        </span><span class="hs-comment">-- Not Read/Show because they respect the type</span><span>
</span><span id="line-1002"></span><span>        </span><span class="hs-comment">-- Not Enum, because newtypes are never in Enum</span><span>
</span><span id="line-1003"></span><span>
</span><span id="line-1004"></span><span>
</span><span id="line-1005"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#non_coercible_class"><span class="hs-identifier hs-type">non_coercible_class</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.Class.html#Class"><span class="hs-identifier hs-type">Class</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span>
</span><span id="line-1006"></span><span class="hs-comment">-- *Never* derive Read, Show, Typeable, Data, Generic, Generic1, Lift</span><span>
</span><span id="line-1007"></span><span class="hs-comment">-- by Coercible, even with -XGeneralizedNewtypeDeriving</span><span>
</span><span id="line-1008"></span><span class="hs-comment">-- Also, avoid Traversable, as the Coercible-derived instance and the &quot;normal&quot;-derived</span><span>
</span><span id="line-1009"></span><span class="hs-comment">-- instance behave differently if there's a non-lawful Applicative out there.</span><span>
</span><span id="line-1010"></span><span class="hs-comment">-- Besides, with roles, Coercible-deriving Traversable is ill-roled.</span><span>
</span><span id="line-1011"></span><span id="non_coercible_class"><span class="annot"><span class="annottext">non_coercible_class :: Class -&gt; Bool
</span><a href="GHC.Tc.Deriv.Utils.html#non_coercible_class"><span class="hs-identifier hs-var hs-var">non_coercible_class</span></a></span></span><span> </span><span id="local-6989586621681169755"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169755"><span class="hs-identifier hs-var">cls</span></a></span></span><span>
</span><span id="line-1012"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Class -&gt; Unique
</span><a href="GHC.Core.Class.html#classKey"><span class="hs-identifier hs-var hs-var">classKey</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169755"><span class="hs-identifier hs-var">cls</span></a></span><span> </span><span class="annot"><span class="annottext">Unique -&gt; [Unique] -&gt; Bool
forall (t :: * -&gt; *) a. (Foldable t, Eq a) =&gt; a -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#elem"><span class="hs-operator hs-var">`elem`</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#readClassKey"><span class="hs-identifier hs-var">readClassKey</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#showClassKey"><span class="hs-identifier hs-var">showClassKey</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#dataClassKey"><span class="hs-identifier hs-var">dataClassKey</span></a></span><span>
</span><span id="line-1013"></span><span>                         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#genClassKey"><span class="hs-identifier hs-var">genClassKey</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#gen1ClassKey"><span class="hs-identifier hs-var">gen1ClassKey</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#typeableClassKey"><span class="hs-identifier hs-var">typeableClassKey</span></a></span><span>
</span><span id="line-1014"></span><span>                         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.html#traversableClassKey"><span class="hs-identifier hs-var">traversableClassKey</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Unique
</span><a href="GHC.Builtin.Names.TH.html#liftClassKey"><span class="hs-identifier hs-var">liftClassKey</span></a></span><span> </span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-1015"></span><span>
</span><span id="line-1016"></span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#badCon"><span class="hs-identifier hs-type">badCon</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.DataCon.html#DataCon"><span class="hs-identifier hs-type">DataCon</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Utils.Outputable.html#SDoc"><span class="hs-identifier hs-type">SDoc</span></a></span><span>
</span><span id="line-1017"></span><span id="badCon"><span class="annot"><span class="annottext">badCon :: DataCon -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Tc.Deriv.Utils.html#badCon"><span class="hs-identifier hs-var hs-var">badCon</span></a></span></span><span> </span><span id="local-6989586621681169753"><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681169753"><span class="hs-identifier hs-var">con</span></a></span></span><span> </span><span id="local-6989586621681169752"><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681169752"><span class="hs-identifier hs-var">msg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#text"><span class="hs-identifier hs-var">text</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Constructor&quot;</span></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#quotes"><span class="hs-identifier hs-var">quotes</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">DataCon -&gt; SDoc
forall a. Outputable a =&gt; a -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#ppr"><span class="hs-identifier hs-var">ppr</span></a></span><span> </span><span class="annot"><span class="annottext">DataCon
</span><a href="#local-6989586621681169753"><span class="hs-identifier hs-var">con</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">SDoc -&gt; SDoc -&gt; SDoc
</span><a href="GHC.Utils.Outputable.html#%3C%2B%3E"><span class="hs-operator hs-var">&lt;+&gt;</span></a></span><span> </span><span class="annot"><span class="annottext">SDoc
</span><a href="#local-6989586621681169752"><span class="hs-identifier hs-var">msg</span></a></span><span>
</span><span id="line-1018"></span><span>
</span><span id="line-1019"></span><span class="hs-comment">------------------------------------------------------------------</span><span>
</span><span id="line-1020"></span><span>
</span><span id="line-1021"></span><span id="local-6989586621681170379"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#newDerivClsInst"><span class="hs-identifier hs-type">newDerivClsInst</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="GHC.Core.TyCo.Rep.html#ThetaType"><span class="hs-identifier hs-type">ThetaType</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DerivSpec"><span class="hs-identifier hs-type">DerivSpec</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681170379"><span class="hs-identifier hs-type">theta</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="GHC.Core.InstEnv.html#ClsInst"><span class="hs-identifier hs-type">ClsInst</span></a></span></span><span>
</span><span id="line-1022"></span><span id="newDerivClsInst"><span class="annot"><span class="annottext">newDerivClsInst :: forall theta. [Type] -&gt; DerivSpec theta -&gt; TcM ClsInst
</span><a href="GHC.Tc.Deriv.Utils.html#newDerivClsInst"><span class="hs-identifier hs-var hs-var">newDerivClsInst</span></a></span></span><span> </span><span id="local-6989586621681169751"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681169751"><span class="hs-identifier hs-var">theta</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#DS"><span class="hs-identifier hs-type">DS</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">ds_name :: forall theta. DerivSpec theta -&gt; Name
</span><a href="GHC.Tc.Deriv.Utils.html#ds_name"><span class="hs-identifier hs-var">ds_name</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681169750"><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681169750"><span class="hs-identifier hs-var">dfun_name</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ds_overlap :: forall theta. DerivSpec theta -&gt; Maybe OverlapMode
</span><a href="GHC.Tc.Deriv.Utils.html#ds_overlap"><span class="hs-identifier hs-var">ds_overlap</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681169749"><span class="annot"><span class="annottext">Maybe OverlapMode
</span><a href="#local-6989586621681169749"><span class="hs-identifier hs-var">overlap_mode</span></a></span></span><span>
</span><span id="line-1023"></span><span>                          </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ds_tvs :: forall theta. DerivSpec theta -&gt; [TyVar]
</span><a href="GHC.Tc.Deriv.Utils.html#ds_tvs"><span class="hs-identifier hs-var">ds_tvs</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681169748"><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681169748"><span class="hs-identifier hs-var">tvs</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ds_cls :: forall theta. DerivSpec theta -&gt; Class
</span><a href="GHC.Tc.Deriv.Utils.html#ds_cls"><span class="hs-identifier hs-var">ds_cls</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681169747"><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169747"><span class="hs-identifier hs-var">clas</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ds_tys :: forall theta. DerivSpec theta -&gt; [Type]
</span><a href="GHC.Tc.Deriv.Utils.html#ds_tys"><span class="hs-identifier hs-var">ds_tys</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="local-6989586621681169746"><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681169746"><span class="hs-identifier hs-var">tys</span></a></span></span><span> </span><span class="hs-special">}</span><span class="hs-special">)</span><span>
</span><span id="line-1024"></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Maybe OverlapMode
-&gt; Name -&gt; [TyVar] -&gt; [Type] -&gt; Class -&gt; [Type] -&gt; TcM ClsInst
</span><a href="GHC.Tc.Utils.Instantiate.html#newClsInst"><span class="hs-identifier hs-var">newClsInst</span></a></span><span> </span><span class="annot"><span class="annottext">Maybe OverlapMode
</span><a href="#local-6989586621681169749"><span class="hs-identifier hs-var">overlap_mode</span></a></span><span> </span><span class="annot"><span class="annottext">Name
</span><a href="#local-6989586621681169750"><span class="hs-identifier hs-var">dfun_name</span></a></span><span> </span><span class="annot"><span class="annottext">[TyVar]
</span><a href="#local-6989586621681169748"><span class="hs-identifier hs-var">tvs</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681169751"><span class="hs-identifier hs-var">theta</span></a></span><span> </span><span class="annot"><span class="annottext">Class
</span><a href="#local-6989586621681169747"><span class="hs-identifier hs-var">clas</span></a></span><span> </span><span class="annot"><span class="annottext">[Type]
</span><a href="#local-6989586621681169746"><span class="hs-identifier hs-var">tys</span></a></span><span>
</span><span id="line-1025"></span><span>
</span><span id="line-1026"></span><span id="local-6989586621681170376"><span class="annot"><a href="GHC.Tc.Deriv.Utils.html#extendLocalInstEnv"><span class="hs-identifier hs-type">extendLocalInstEnv</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="GHC.Core.InstEnv.html#ClsInst"><span class="hs-identifier hs-type">ClsInst</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681170376"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="GHC.Tc.Types.html#TcM"><span class="hs-identifier hs-type">TcM</span></a></span><span> </span><span class="annot"><a href="#local-6989586621681170376"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-1027"></span><span class="hs-comment">-- Add new locally-defined instances; don't bother to check</span><span>
</span><span id="line-1028"></span><span class="hs-comment">-- for functional dependency errors -- that'll happen in GHC.Tc.TyCl.Instance</span><span>
</span><span id="line-1029"></span><span id="extendLocalInstEnv"><span class="annot"><span class="annottext">extendLocalInstEnv :: forall a. [ClsInst] -&gt; TcM a -&gt; TcM a
</span><a href="GHC.Tc.Deriv.Utils.html#extendLocalInstEnv"><span class="hs-identifier hs-var hs-var">extendLocalInstEnv</span></a></span></span><span> </span><span id="local-6989586621681169743"><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681169743"><span class="hs-identifier hs-var">dfuns</span></a></span></span><span> </span><span id="local-6989586621681169742"><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681169742"><span class="hs-identifier hs-var">thing_inside</span></a></span></span><span>
</span><span id="line-1030"></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span> </span><span class="hs-special">{</span><span> </span><span id="local-6989586621681169741"><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681169741"><span class="hs-identifier hs-var">env</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">TcRnIf TcGblEnv TcLclEnv TcGblEnv
forall gbl lcl. TcRnIf gbl lcl gbl
</span><a href="GHC.Tc.Utils.Monad.html#getGblEnv"><span class="hs-identifier hs-var">getGblEnv</span></a></span><span>
</span><span id="line-1031"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="hs-keyword">let</span><span>  </span><span id="local-6989586621681169739"><span class="annot"><span class="annottext">inst_env' :: InstEnv
</span><a href="#local-6989586621681169739"><span class="hs-identifier hs-var hs-var">inst_env'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InstEnv -&gt; [ClsInst] -&gt; InstEnv
</span><a href="GHC.Core.InstEnv.html#extendInstEnvList"><span class="hs-identifier hs-var">extendInstEnvList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">TcGblEnv -&gt; InstEnv
</span><a href="GHC.Tc.Types.html#tcg_inst_env"><span class="hs-identifier hs-var hs-var">tcg_inst_env</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681169741"><span class="hs-identifier hs-var">env</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[ClsInst]
</span><a href="#local-6989586621681169743"><span class="hs-identifier hs-var">dfuns</span></a></span><span>
</span><span id="line-1032"></span><span>             </span><span id="local-6989586621681169736"><span class="annot"><span class="annottext">env' :: TcGblEnv
</span><a href="#local-6989586621681169736"><span class="hs-identifier hs-var hs-var">env'</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681169741"><span class="hs-identifier hs-var">env</span></a></span><span> </span><span class="hs-special">{</span><span> </span><span class="annot"><span class="annottext">tcg_inst_env :: InstEnv
</span><a href="GHC.Tc.Types.html#tcg_inst_env"><span class="hs-identifier hs-var">tcg_inst_env</span></a></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InstEnv
</span><a href="#local-6989586621681169739"><span class="hs-identifier hs-var">inst_env'</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1033"></span><span>      </span><span class="hs-special">;</span><span> </span><span class="annot"><span class="annottext">TcGblEnv -&gt; TcM a -&gt; TcM a
forall gbl lcl a. gbl -&gt; TcRnIf gbl lcl a -&gt; TcRnIf gbl lcl a
</span><a href="GHC.Tc.Utils.Monad.html#setGblEnv"><span class="hs-identifier hs-var">setGblEnv</span></a></span><span> </span><span class="annot"><span class="annottext">TcGblEnv
</span><a href="#local-6989586621681169736"><span class="hs-identifier hs-var">env'</span></a></span><span> </span><span class="annot"><span class="annottext">TcM a
</span><a href="#local-6989586621681169742"><span class="hs-identifier hs-var">thing_inside</span></a></span><span> </span><span class="hs-special">}</span><span>
</span><span id="line-1034"></span><span>
</span><span id="line-1035"></span><span class="hs-comment">{-
Note [Deriving any class]
~~~~~~~~~~~~~~~~~~~~~~~~~
Classic uses of a deriving clause, or a standalone-deriving declaration, are
for:
  * a stock class like Eq or Show, for which GHC knows how to generate
    the instance code
  * a newtype, via the mechanism enabled by GeneralizedNewtypeDeriving

The DeriveAnyClass extension adds a third way to derive instances, based on
empty instance declarations.

The canonical use case is in combination with GHC.Generics and default method
signatures. These allow us to have instance declarations being empty, but still
useful, e.g.

  data T a = ...blah..blah... deriving( Generic )
  instance C a =&gt; C (T a)  -- No 'where' clause

where C is some &quot;random&quot; user-defined class.

This boilerplate code can be replaced by the more compact

  data T a = ...blah..blah... deriving( Generic, C )

if DeriveAnyClass is enabled.

This is not restricted to Generics; any class can be derived, simply giving
rise to an empty instance.

See Note [Gathering and simplifying constraints for DeriveAnyClass] in
GHC.Tc.Deriv.Infer for an explanation hof how the instance context is inferred for
DeriveAnyClass.

Note [Check that the type variable is truly universal]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
For Functor and Traversable instances, we must check that the *last argument*
of the type constructor is used truly universally quantified.  Example

   data T a b where
     T1 :: a -&gt; b -&gt; T a b      -- Fine! Vanilla H-98
     T2 :: b -&gt; c -&gt; T a b      -- Fine! Existential c, but we can still map over 'b'
     T3 :: b -&gt; T Int b         -- Fine! Constraint 'a', but 'b' is still polymorphic
     T4 :: Ord b =&gt; b -&gt; T a b  -- No!  'b' is constrained
     T5 :: b -&gt; T b b           -- No!  'b' is constrained
     T6 :: T a (b,b)            -- No!  'b' is constrained

Notice that only the first of these constructors is vanilla H-98. We only
need to take care about the last argument (b in this case).  See #8678.
Eg. for T1-T3 we can write

     fmap f (T1 a b) = T1 a (f b)
     fmap f (T2 b c) = T2 (f b) c
     fmap f (T3 x)   = T3 (f x)

We need not perform these checks for Foldable instances, however, since
functions in Foldable can only consume existentially quantified type variables,
rather than produce them (as is the case in Functor and Traversable functions.)
As a result, T can have a derived Foldable instance:

    foldr f z (T1 a b) = f b z
    foldr f z (T2 b c) = f b z
    foldr f z (T3 x)   = f x z
    foldr f z (T4 x)   = f x z
    foldr f z (T5 x)   = f x z
    foldr _ z T6       = z

See Note [DeriveFoldable with ExistentialQuantification] in GHC.Tc.Deriv.Functor.

For Functor and Traversable, we must take care not to let type synonyms
unfairly reject a type for not being truly universally quantified. An
example of this is:

    type C (a :: Constraint) b = a
    data T a b = C (Show a) b =&gt; MkT b

Here, the existential context (C (Show a) b) does technically mention the last
type variable b. But this is OK, because expanding the type synonym C would
give us the context (Show a), which doesn't mention b. Therefore, we must make
sure to expand type synonyms before performing this check. Not doing so led to
#13813.
-}</span><span>
</span><span id="line-1117"></span></pre></body></html>